OS X是否支持POSIX会话? [英] Does OS X support POSIX sessions?
问题描述
我正在研究一个可以充分利用POSIX会话的项目(如此处),但现在不确定我是否误解了这个概念和/或OS X是否支持流程会话.
I am working on a project which could make good use of POSIX sessions (as described here) but I'm now uncertain whether I'm misunderstanding the concept and/or whether OS X even supports process sessions.
OS X 10.9有一个setsid(2)
系统调用,但是用参数0, 0
调用它似乎没有作用.查看ps -e -o pid,pgid,sess
的输出显示,所有进程的会话ID为0
:
OS X 10.9 has a setsid(2)
system call but calling it with arguments 0, 0
seems to do noting. And looking at the output of ps -e -o pid,pgid,sess
shows that all processes have a session ID of 0
:
PID PGID SESS
1 1 0
11 11 0
12 12 0
13 13 0
14 14 0
15 15 0
16 16 0
17 17 0
[...]
OS X是否支持POSIX会话进程,如果不支持,是否存在另一种机制,例如一个外壳程序可以用来向该外壳程序启动的所有进程发送信号?
Does OS X support POSIX sessions for processes and, if not, is there another mechanism in place that e.g. a shell can use to send a signal to all processes started from that shell?
除了查看系统上的活动进程外,我还使用了 ersatz-setsid 命令行工具在新会话中运行流程,但没有成功:
Besides looking at active processes on my system, I used the ersatz-setsid command line tool to run a process in a new session, but without success:
$ ./setsid sleep 1000
$ ps -eo pid,pgid,sess,command
PID PGID SESS COMMAND
[...]
10650 10650 0 sleep 1000
[...]
推荐答案
以我的经验,Mac OSX 确实支持posix会话. getsid()
系统调用起作用.但是ps
实用程序不能(ps -o sess
为所有进程生成0
).
In my experience, Mac OSX does support posix sessions. The getsid()
system call works. But the ps
utility does not (ps -o sess
produces 0
for all processes).
这篇关于OS X是否支持POSIX会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!