exit

How do you return to a sourced bash script?

你。 提交于 2019-11-26 17:45:52
问题 I use a script that extends using the bash source feature; #!/bin/bash source someneatscriptthatendsprematurely.sh I would like to be able to return from that script, without breaking the main script. Using exit breaks the main script, return is only valid in functions and experimenting with $(exit 1) does not seem to work either. So, is it possible to return in a sub-bash script without breaking the main bash? Any help appreciated! 回答1: You need the return statement: return [n] Causes a

Ending a Program Mid-Run

…衆ロ難τιáo~ 提交于 2019-11-26 17:12:23
问题 pythoncom.PumpMessages() From what I understand this line basically tells the program to wait forever. For my purposes it seems to be working. However, I'd like to be able to end the program given the right stimulus. How would one go about ending the above line, or stopping the program from running any further. 回答1: According to these docs, pythoncom.PumpMessages() : Pumps all messages for the current thread until a WM_QUIT message. So one way to stop collecting messages is by posting a WM

call exit(0) in iphone app

偶尔善良 提交于 2019-11-26 16:41:41
At some point in my application I have done this exit(0) which crashes my app. But I haven't figured out what method gets called when this executes. I've put messages in: (void)applicationWillTerminate:(UIApplication *)application (void)applicationDidEnterBackground:(UIApplication *)application But none of this seem to get called! Any idea about what method is called when exit(0) is done? Jeff Wolski From Apple's Human User Guidelines... Don’t Quit Programmatically Never quit an iOS application programmatically because people tend to interpret this as a crash. However, if external

simple IPython example raises exception on sys.exit()

孤街醉人 提交于 2019-11-26 16:36:19
问题 I'm doing some very simple PySide (and PyQt) tutorials in IPython. One tutorial just creates a window with some sliders to demonstrate slots and signals. When I close the window of the running demo application, I see this error: An exception has occurred, use %tb to see the full traceback. SystemExit: 0 To exit: use 'exit', 'quit', or Ctrl-D. So I run %tb and get this: SystemExit Traceback (most recent call last) /Workspaces/scratch/<ipython-input-1-88966dcfb499> in <module>() 33 34 if __name

Application.Exit

旧街凉风 提交于 2019-11-26 16:32:59
I am using VSTS 2008 + .Net 3.5 + C# to develop Windows Forms application. My confusion is, seems Application.Exit does not force application to terminate? If not, which method should I call to make application terminate? EDIT 1: Normally the main method is like this, how to exit Main function gracefully without calling Environment.Exit? static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); try { Application.Run(new Form1()); } catch (Exception ex) { Console.WriteLine (ex.Message); } } thanks in advance, George Application.Exit really just

Gracefully Exit Explorer (Programmatically)

Deadly 提交于 2019-11-26 15:53:15
问题 How do you gracefully close Explorer programmatically? By that I mean, how do you invoke this function programmatically: Edit: Typo in the picture, it should say "Ctrl-Shift-Right-Click" instead of "Shift-Click". 回答1: I debugged this out of curiosity. All it does is post a message to one of explorer's windows: BOOL ExitExplorer() { HWND hWndTray = FindWindow(_T("Shell_TrayWnd"), NULL); return PostMessage(hWndTray, 0x5B4, 0, 0); } Of course this is an undocumented WM_USER message so the

ruby system command check exit code

做~自己de王妃 提交于 2019-11-26 15:36:45
问题 I have a bunch of system calls in ruby such as the following and I want to check their exit codes simultaneously so that my script exits out if that command fails. system("VBoxManage createvm --name test1") system("ruby test.rb") I want something like system("VBoxManage createvm --name test1", 0) <-- where the second parameter checks the exit code and confirms that that system call was successful, and if not, it'll raise an error or do something of that sort. Is that possible at all? I've

SQL Server - stop or break execution of a SQL script

孤街醉人 提交于 2019-11-26 14:54:05
Is there a way to immediately stop execution of a SQL script in SQL server, like a "break" or "exit" command? I have a script that does some validation and lookups before it starts doing inserts, and I want it to stop if any of the validations or lookups fail. The raiserror method raiserror('Oh no a fatal error', 20, -1) with log This will terminate the connection, thereby stopping the rest of the script from running. Note that both severity level 20 or higher and the WITH LOG option are necessary for it to work this way. This even works with GO statements, eg. print 'hi' go raiserror('Oh no a

PHP: Utilizing exit(); or die(); after header(“Location: ”);

微笑、不失礼 提交于 2019-11-26 14:41:30
I have a user login/registration system that simply uses // execute queries, set cookies, etc. here header("Location: " . getenv("HTTP_REFERER")); I recently read a post about exit(); and die(); and had no idea that I was supposed to be using these. From what I understand, they make it end the PHP? Is that correct? What's the best way I can work toward this, simply adding one of these functions directly after ever header(); execution I have? I have AJAX, jQuery reading through my login.php/register.php, will this be affect in any way? Edit: Other than after header();, where else should I be

Doing something before program exit

旧城冷巷雨未停 提交于 2019-11-26 13:00:35
How can you have a function or something that will be executed before your program quits? I have a script that will be constantly running in the background, and I need it to save some data to a file before it exits. Is there a standard way of doing this? Check out the atexit module: http://docs.python.org/library/atexit.html For example, if I wanted to print a message when my application was terminating: import atexit def exit_handler(): print 'My application is ending!' atexit.register(exit_handler) Just be aware that this works great for normal termination of the script, but it won't get