My code uses fork() and waitpid(-1,&WNOHANG) to spawn multiple children. Each of these children uses $pid = system(1,"start $executable $args") to start a program. This program sometimes hangs, and I would like to be able to kill it after some length of time. The $pid value returned by my system command is not the one I need to kill the process (From my research I believe this has to do with a shell?) and I'm stuck as to how to get around this. I've experimented with a piped open and had no luck, but I'm not sure if I'm doing it correctly. Any suggestions as to how I can get a PID so that I can kill the process later if needed? Sorry if this has already been answered, but I'm fairly new to coding and Perl, and I've looked at several similar questions and can't figure out how to apply them to get a workable solution. Also, my OS is Windows 7 64 bit and I can't use any modules that aren't standard. Thanks in advance for any advice!
Update: Thanks for all the replies! I found a not so elegant workaround that completely avoids the problem of getting the PID. For reasons other than the PID problem, I have to copy the executable to a new directory before I run it, and I now give the duplicate a unique name each time I copy it. Then, if it is still going after a certain amount of time, I kill it with start("Taskkill /IM $unique_executable /F"). A little bit clunky, but it works for my purposes.