[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: io.popen processes hanging around after close
- From: Justin Cormack <justin@...>
- Date: Mon, 28 Oct 2013 16:42:45 +0000
On Mon, Oct 28, 2013 at 4:29 PM, Rena <firstname.lastname@example.org> wrote:
> On Mon, Oct 28, 2013 at 11:51 AM, Justin Cormack
> <email@example.com> wrote:
>> On Mon, Oct 28, 2013 at 3:35 PM, Rena <firstname.lastname@example.org> wrote:
>> > In my app I open a few processes using io.popen(), then read their
>> > output
>> > using posix.fileno() and posix.rpoll() to see if there's data available.
>> > When my app shuts down however (using os.exit(0)), even if I close the
>> > process file handles, they remain running in the background. How do I
>> > prevent this? I do both process:close() and posix.close(fd). (I found
>> > without the latter, the former would just hang...)
>> You can either send a kill (posix.kill) signal to the child, or make
>> the child test to see if the pipe is still open - it depends if it is
>> doing anything or is blocked, and how much it is under your control.
> But how do I get the child's PID?
Ah yes. Try using 0 (all processes in process group), at least that
works for Linux and NetBSD, not sure about OSX.