开发者

Calling setpgid on child process UNIX

开发者 https://www.devze.com 2022-12-08 03:52 出处:网络
I want a alternative function call for setpgid to call on a process that has done exec() call. setpgid returns error if it is called ona child which has alread开发者_如何学Goy called exec.

I want a alternative function call for setpgid to call on a process that has done exec() call. setpgid returns error if it is called on a child which has alread开发者_如何学Goy called exec. Does any alternative function exists?


After a successful exec, the process group can only be changed by the process itself. The most straightforward way to change it from another process, if the child is cooperating, would be to use a pipe or other interprocess communication mechanism to ask the child to change its own process group. Another alternative would be to attach to the child process (e.g. with ptrace, gdb, or an OS-specific mechansim) and execute the setpgid() system call from within the context of the child process. Other alternatives such as a new kernel module or modifying kernel memory require root or special system capabilities and are likely to be much worse than the other approaches.

0

精彩评论

暂无评论...
验证码 换一张
取 消