setpgrp

setpgrpPID,PGRP
This function sets the current process group
(PGRP) for the specified
PID (use a PID of
0 for the current process). Invoking setpgrp will raise an exception if used on a
machine that doesn’t implement setpgrp(2). Beware:
some systems will ignore the arguments you provide and always do
setpgrp(0, $$). Fortunately, those
are the arguments one usually wants to provide. If the arguments are
omitted, they default to 0,0. The BSD
4.2 version of setpgrp did not accept
any arguments, but in BSD 4.4, it is a synonym for the setpgid function. For better portability (by
some definition), use the setpgid
function in the POSIX module directly. If what you’re really trying to do is
daemonize your script, consider the POSIX::setsid function as well. Note that the
POSIX version of setpgrp does not
accept arguments, so only setpgrp(0,0) is truly portable.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access