mark@comp.vuw.ac.nz (Mark Davies) (03/01/90)
When forking off children to run in the foreground both tcsh (and csh I presume) and bash do basically the following (in the child process): pgrp = getpid(); : ioctl(cntl_tty, TIOCSPGRP, &pgrp); : setpgrp(0, pgrp); If I remember correctly from the discussion here a few months ago (and the comments in the bash code) the ioctl is done first to avoid a race condition. All well and good, but now POSIX (in the form of HP-UX 7.0) makes an appearance and doing things in the above order causes the ioctl to fail with EPERM which, reading the manual, means: "The process ID referenced by arg is a supported value but does not match the process group ID of a process in the same session as the calling process." This is reasonable as the process group with that ID is not actually created until the setpgrp. Reversing the order of the setpgrp and ioctl allows things to work, but what about the race condition? What is the correct way to do this with POSIX style job control? cheers mark