2008 May 30 Friday (五月 三十日 金曜日)

本文介绍了通过setsid创建新的会话并设置进程为会话领导者的方法,以及如何使用tcgetpgrp和tcsetpgrp获取和设置终端的前台进程组。这些函数允许程序更好地控制与终端交互的方式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#include <unistd.h>   pid_t setsid(void);     setsid()  creates  a new session if the calling process is not a process group leader.  The calling process is the leader of the new session, the process group leader of the new process group, and has no controlling tty.  The process group ID and session ID of the calling process are set to the PID of the calling process.  The calling process will be the only process in this new process group and in this new session.   #include <unistd.h>   pid_t tcgetpgrp(int fd);   int tcsetpgrp(int fd, pid_t pgrp);   The function tcgetpgrp() returns the process group ID of the foreground process group on the terminal associated to fd, which must be the controlling terminal of the calling process.   The function tcsetpgrp() makes the process group with process group ID pgrp the foreground process group on the terminal associated to fd, which must be the controlling terminal of the calling process, and still be associated with its session. Moreover, pgrp must be a (nonempty) process group belonging to the same session as the calling process.   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.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值