Timeline for How do I execute a program or call a system command?
Current License: CC BY-SA 4.0
18 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 2, 2022 at 8:57 | review | Suggested edits | |||
Apr 2, 2022 at 22:42 | |||||
Nov 29, 2019 at 21:46 | history | edited | Peter Mortensen | CC BY-SA 4.0 |
Active reading [<http://en.wikipedia.org/wiki/Central_processing_unit> <http://en.wikipedia.org/wiki/Documentation> <https://en.wikipedia.org/wiki/FreeBSD>]. Made compliant with the Jon Skeet Decree - <https://twitter.com/PeterMortensen/status/976400000942034944>.
|
Feb 24, 2019 at 19:38 | comment | added | Charlie Parker |
your answer seems strange to me. I just opened a subprocess.Popen and nothing bad happened (not had to wait). Why exactly do we need to worry about the scenario you are pointing out? I'm skeptical.
|
|
Mar 8, 2018 at 8:56 | comment | added | Dr_Zaszuś |
stdout=subprocess.PIPE will make your code hang up if you have long output from a child. For more details see thraxil.org/users/anders/posts/2008/03/13/…
|
|
S Jul 27, 2017 at 21:35 | history | suggested | rstackhouse | CC BY-SA 3.0 |
Added link to win api docs
|
Jul 27, 2017 at 20:40 | review | Suggested edits | |||
S Jul 27, 2017 at 21:35 | |||||
Oct 27, 2015 at 17:37 | comment | added | Eryk Sun |
I didn't mean that executing as a detached process is incorrect. That said, you may need to set the standard handles to files, pipes, or os.devnull because some console programs exit with an error otherwise. Create a new console when you want the child process to interact with the user concurrently with the parent process. It would be confusing to try to do both in a single window.
|
|
Oct 27, 2015 at 10:32 | history | edited | newtover | CC BY-SA 3.0 |
referenced @eryksun's remark
|
Oct 27, 2015 at 0:27 | comment | added | Eryk Sun |
The following is incorrect: "[o]n windows (win xp), the parent process will not finish until the longtask.py has finished its work". The parent will exit normally, but the console window (conhost.exe instance) only closes when the last attached process exits, and the child may have inherited the parent's console. Setting DETACHED_PROCESS in creationflags avoids this by preventing the child from inheriting or creating a console. If you instead want a new console, use CREATE_NEW_CONSOLE (0x00000010).
|
|
May 5, 2015 at 13:13 | comment | added | SuperBiasedMan | Is there any significance to using '0x00000008'? Is that a specific value that has to be used or one of multiple options? | |
Oct 30, 2014 at 5:45 | comment | added | ubershmekel |
I'm on Windows 8.1 and calc seems to survive the closing of python .
|
|
Oct 28, 2014 at 12:25 | comment | added | newtover |
@ubershmekel, I am not sure what you mean and don't have a windows installation. If I recall correctly, without the flags you can not close the cmd instance from which you started the calc .
|
|
Oct 27, 2014 at 21:01 | comment | added | ubershmekel |
I'm seeing import subprocess as sp;sp.Popen('calc') not waiting for the subprocess to complete. It seems the creationflags aren't necessary. What am I missing?
|
|
Nov 16, 2012 at 14:16 | comment | added | jfs | you might also need CREATE_NEW_PROCESS_GROUP flag. See Popen waiting for child process even when the immediate child has terminated | |
Apr 16, 2012 at 10:04 | comment | added | Alexey Lebedev | Windows gotcha: even though I spawned process with DETACHED_PROCESS, when I killed my Python daemon all ports opened by it wouldn't free until all spawned processes terminate. WScript.Shell solved all my problems. Example here: pastebin.com/xGmuvwSx | |
Apr 9, 2010 at 8:09 | comment | added | maranas | i noticed a possible "quirk" with developing py2exe apps in pydev+eclipse. i was able to tell that the main script was not detached because eclipse's output window was not terminating; even if the script executes to completion it is still waiting for returns. but, when i tried compiling to a py2exe executable, the expected behavior occurs (runs the processes as detached, then quits). i am not sure, but the executable name is not in the process list anymore. this works for all approaches (os.system("start *"), os.spawnl with os.P_DETACH, subprocs, etc.) | |
Apr 8, 2010 at 19:25 | history | edited | newtover | CC BY-SA 2.5 |
added 47 characters in body
|
Feb 12, 2010 at 10:15 | history | answered | newtover | CC BY-SA 2.5 |