Re: Best way to prevent zombie processes

2015-06-01 Thread Marko Rauhamaa
Grant Edwards : > On 2015-05-31, Marko Rauhamaa wrote: >> If you don't care to know when child processes exit, you can simply >> ignore the SIGCHLD signal: >> >> import signal >> signal.signal(signal.SIGCHLD, signal.SIG_IGN) >> >> That will prevent zombies from appearing. > > Bravo! I've

Re: Best way to prevent zombie processes

2015-06-01 Thread Grant Edwards
On 2015-05-31, Marko Rauhamaa wrote: > Cecil Westerhof : > >> At the moment I have the following code: >> os.chdir(directory) >> for document in documents: >> subprocess.Popen(['evince', document]) >> >> With this I can open several documents at once. But there is no way to >> know

Re: Best way to prevent zombie processes

2015-06-01 Thread Cecil Westerhof
Op Monday 1 Jun 2015 15:32 CEST schreef Marko Rauhamaa: > Cecil Westerhof : > >> Thread(target = p.wait).start() >> >> [...] >> >> How about this way of solving it? > > It works. That I knew: I tested it before I posted it. What I mend is this better, worse, or the same as working with signal. In

Re: Best way to prevent zombie processes

2015-06-01 Thread Cecil Westerhof
Op Monday 1 Jun 2015 14:16 CEST schreef Cecil Westerhof: > Op Sunday 31 May 2015 23:33 CEST schreef Cecil Westerhof: > >> At the moment I have the following code: >> os.chdir(directory) >> for document in documents: >> subprocess.Popen(['evince', document]) >> >> With this I can open several docum

Re: Best way to prevent zombie processes

2015-06-01 Thread Marko Rauhamaa
Cecil Westerhof : > Thread(target = p.wait).start() > > [...] > > How about this way of solving it? It works. Marko -- https://mail.python.org/mailman/listinfo/python-list

Re: Best way to prevent zombie processes

2015-06-01 Thread Cecil Westerhof
Op Sunday 31 May 2015 23:33 CEST schreef Cecil Westerhof: > At the moment I have the following code: > os.chdir(directory) > for document in documents: > subprocess.Popen(['evince', document]) > > With this I can open several documents at once. But there is no way > to know when those documents ar

Re: Best way to prevent zombie processes

2015-06-01 Thread Marko Rauhamaa
Cecil Westerhof : > It works. What I find kind of strange because > https://docs.python.org/2/library/signal.html You should not rely on Python documentation on Linux system specifics. The wait(2) manual page states: POSIX.1-2001 specifies that if the disposition of SIGCHLD is set to

Re: Best way to prevent zombie processes

2015-06-01 Thread Marko Rauhamaa
Chris Angelico : > On Mon, Jun 1, 2015 at 7:20 PM, Cecil Westerhof wrote: >> But >> what if I want for certain Popen signals SIG_IGN and others SIG_DFL. >> How should I do that? > > You can't. A signal is a signal; you can't specify default handling > for some and not others. The only way is to a

Re: Best way to prevent zombie processes

2015-06-01 Thread Chris Angelico
On Mon, Jun 1, 2015 at 7:20 PM, Cecil Westerhof wrote: > But > what if I want for certain Popen signals SIG_IGN and others SIG_DFL. > How should I do that? You can't. A signal is a signal; you can't specify default handling for some and not others. The only way is to actually handle them, and the

Re: Best way to prevent zombie processes

2015-06-01 Thread Cecil Westerhof
Op Monday 1 Jun 2015 03:03 CEST schreef Cameron Simpson: > On 31May2015 23:33, Cecil Westerhof wrote: >> At the moment I have the following code: >> os.chdir(directory) >> for document in documents: >> subprocess.Popen(['evince', document]) >> >> With this I can open several documents at once. Bu

Re: Best way to prevent zombie processes

2015-06-01 Thread Cecil Westerhof
Op Monday 1 Jun 2015 00:22 CEST schreef Marko Rauhamaa: > Cecil Westerhof : > >> At the moment I have the following code: >> os.chdir(directory) >> for document in documents: >> subprocess.Popen(['evince', document]) >> >> With this I can open several documents at once. But there is no way >> to k

Re: Best way to prevent zombie processes

2015-05-31 Thread Ben Finney
Cameron Simpson writes: > The standard trick is to make the process a grandchild instead of a > child. Fork, kick off subprocess, exit (the forked child). For Cecil Westerhof's benefit: If you haven't seen it, the ‘python-daemon’ library is designed to get this, and other fiddly aspects of daem

Re: Best way to prevent zombie processes

2015-05-31 Thread Cameron Simpson
On 31May2015 23:33, Cecil Westerhof wrote: At the moment I have the following code: os.chdir(directory) for document in documents: subprocess.Popen(['evince', document]) With this I can open several documents at once. But there is no way to know when those documents are going to be

Re: Best way to prevent zombie processes

2015-05-31 Thread Marko Rauhamaa
Cecil Westerhof : > At the moment I have the following code: > os.chdir(directory) > for document in documents: > subprocess.Popen(['evince', document]) > > With this I can open several documents at once. But there is no way to > know when those documents are going to be closed. Th

Best way to prevent zombie processes

2015-05-31 Thread Cecil Westerhof
At the moment I have the following code: os.chdir(directory) for document in documents: subprocess.Popen(['evince', document]) With this I can open several documents at once. But there is no way to know when those documents are going to be closed. This could/will lead to zombie pro