Re: Debugging process launching code
Re: Debugging process launching code
- Subject: Re: Debugging process launching code
- From: Ingemar Ragnemalm <email@hidden>
- Date: Mon, 22 Aug 2011 16:32:38 +0200
Dave Keck wrote:
How would you debug a problem like this?
Determine why forkpty() is failing by checking errno; see 'man
forkpty'. Perhaps you aren't closing your file descriptors.
Are there pitfalls and limitations in process launching that I ought to know about?
Yes, there are limitations on forking; see 'man fork'. You need to
wait on your child processes to have their state cleaned up within the
kernel. Failing to do so will prevent you from forking new processes.
Thanks to Dave and Jonas for the advice!
My checks for terminated processes were not complete, and, in
particular, my manual process termination wasn't safe. I used kill()
with SIGTERM, and if that failed, SIGKILL, but if that failed I just
ignored it. After testing this thoroughly, I have found that SIGKILL
often fails, which then leaves that process in an unknown state,
possibly blocking pty's.
I am not sure if that is an expected behavior. My current solution is to
try SIGKILL over and over, up to 1000 times, until it works. I find that
it usually works after one or two tries, but sometimes I see as much as
ten tries. I have tested for a whikle and it hasn't failed me so far.
But is this violent bashing against a process until it dies, is this
really the way to do it?
/Ingemar
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden