Ehud Karni wrote:
Caution: untested suggestion.
You can use alarm(2) in the child process before `exec'ing the ping.
Then it either will finish normally (exit 0) or will fail for any
reason (including SIGALRM).
No good
First, I can't send a SIGALRM to ping - it ignores it. That's not a real problem. I can send it to the parent process, and then do a signal handler that translates ALRM on the parent to INT on the child, and do a waitpid as suggested.In this way, you can use blocking `waitpid' in the parent process.
If you try my suggestion, please report here.
The more serious problem is that ALRM has a resolution of "seconds", which is not good enough. Obviously, I can simulate the same behavior with a THIRD process. The following schema:
parent does waitpid on child 1 only
child 1 does "execve ping"
child 2 does select for timeout, and then sends SIGINT to child 1.
When parent's waitpid returns, it sends SIGKILL to child 2.
While I think this will work, it's too twisted to contemplate at this time of the day. If nothing better comes along by tomorrow, I'll have a look at this. Can anyone spot a race here? Also, are there any unwanted implications to using SIGKILL in non-emergency situations? I would rather not use SIGTERM or SIGINT, as each of these processes carries around the entire Wine environment. I would like to avoid using threads, for the same reason. Too much factors, not enough certainty.
On second thought, I can get rid of the SIGKILL by having that process call "exit" after the select+kill, and just send it SIGALRM from the parent before doing waitpid on it.Ehud.
Shachar
-- Shachar Shemesh Lingnu Open Source Consulting ltd. http://www.lingnu.com/
================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
