Keep It Simple, Stupid | |
PerlMonks |
Re: Implementing signals for Win32 Perl using named pipesby cdarke (Prior) |
on Mar 11, 2008 at 12:57 UTC ( [id://673478]=note: print w/replies, xml ) | Need Help?? |
I don't wish to be a wet blanket on what, to me, seems like a neat idea (but I will anyway). Using the PID for the name of a pipe could give a race condition: rare, but possible. Senario: 1. Process A wants to send a signal to Process B, so opens the pipe.(CreateFile). 2. Process B ends. 3. Process C starts with the same PID as Process B. PIDs can get reused at once on Windows. 4. Process A sends the signal, but to C instead of B. A "linger" mechanism is required, or maybe some other identifier to be passed down the pipe? At least the process can detect if the pipe already exists before creating it, but the possibility of a race still exists in the period between Process A getting the PID and actually sending the signal. There are also issues to be thought through with threads, particularly considering the implementation of fork. Using a TID rather than a PID may resolve them, and make the race condition less likely, but still not impossible. Update: What would be really good is an implementation of waitid() with siginfo_t fully supported.
In Section
Seekers of Perl Wisdom
|
|