process-group

Sending a process to the background and returning control to my shell

≯℡__Kan透↙ 提交于 2020-01-12 03:33:07
问题 I am programming a shell for my CS class and part of the project involves running a process in the background if the '&' character is passed in by the user. If a process is run in the foreground, I simply execvp the process and it remains in control of the terminal since it is in the foreground. However, if it is a background process, I must return control to my main shell after starting the execution of the process. I understand that the system call tcsetpgrp(pid_t) places the process passed

I have “trap 'echo ignore' USR1” in my called script, why does the calling script get killed?

不问归期 提交于 2019-12-24 17:42:11
问题 Say I have these two bash scripts: /tmp/trapper: #!/bin/bash trap 'echo trapper: ignoring USR1' USR1 "$(dirname $0)"/usr1er & p=$! sleep 1 echo trapper: now killing usr1er kill $p echo trapper: sleeping sleep 1 echo trapper: reached end of trapper /tmp/usr1er: #!/bin/bash trap 'echo "usr1er: EXIT received, sending USR1"; kill -USR1 0' EXIT while sleep 1;do echo usr1er: sleeping;done trapper is supposed to trap USR1 and simply ignore it. It starts usr1er, which kills its process group with the

How to start a process in its own process group?

泪湿孤枕 提交于 2019-12-07 02:54:56
问题 I would like to start a process in its own process group (or, alternatively, change its group once started) and: have the processes in the group respond to Ctrl + C from the terminal get the id of the process group so that I can terminate all the processes in the group via the kill command. Note: I tried setsid prog [args] but the processes do not respond to Ctrl+C from the terminal nor I could get the new process group id. I also tried to change the process group via Perl's setpgrp($pid,

How to set process group of a shell script

天大地大妈咪最大 提交于 2019-11-28 11:52:58
How to set process group of a shell script ? Also I want all the child process to be in the same process group I expect something similar to setpgid() in C. As PSkocik points out , it is possible to run a process in its own process group, in most shells, by activating job control (“monitor mode”). (set -m; exec process_in_its_own_group) Linux has a setsid utility, which runs the command passed as argument in its own session (using the eponymous system call ). This is stronger than running it in its own process group à la setpgrp , but that may be ok for your purpose. If you want to place the

How to set process group of a shell script

丶灬走出姿态 提交于 2019-11-27 06:34:15
问题 How to set process group of a shell script ? Also I want all the child process to be in the same process group I expect something similar to setpgid() in C. 回答1: As PSkocik points out, it is possible to run a process in its own process group, in most shells, by activating job control (“monitor mode”). (set -m; exec process_in_its_own_group) Linux has a setsid utility, which runs the command passed as argument in its own session (using the eponymous system call). This is stronger than running