How do I get tcsetpgrp() to work in C?

后端 未结 3 467
情歌与酒
情歌与酒 2020-12-03 11:04

I\'m trying to give a child process (via fork()) foreground access to the terminal.

After I fork(), I run the following code in the child p

3条回答
  •  时光取名叫无心
    2020-12-03 11:39

    man 3 tcsetpgrp states:

    If tcsetpgrp() is called by a member of a background process group in its session, and the calling process is not blocking or ignoring SIGTTOU, a SIGTTOU signal is sent to all members of this background process group.

    You need to call tcsetpgrp() in your parent process not in child. However if your parent process started and moved into background it will receive SIGTTOU and will be stopped.

提交回复
热议问题