- 论坛徽章:
- 0
|
本帖最后由 bsknight 于 2011-02-20 17:22 编辑
- #define PSCMD "ps -o pid,ppid,state,tty,command"
- int
- main(void)
- {
- pid_t pid;
- if ((pid = fork()) < 0)
- err_sys("fork error");
- else if (pid == 0) /* child */
- exit(0);
- /* parent */
-
- system(PSCMD);
- abort();
- }
复制代码 为什么结果中,子进程变成了zombie?
主进程是在system(PSCMD);之后被终止,那时应该能对子进程进行处理吧?- PID PPID S TT COMMAND
- 2217 2184 S pts/1 bash
- 2384 2217 S pts/1 ./a.out
- 2385 2384 Z pts/1 [a.out] <defunct>
- 2386 2384 S pts/1 sh -c ps -o pid,ppid,state,tty,command
- 2387 2386 R pts/1 ps -o pid,ppid,state,tty,command
- Aborted
复制代码 注:我是双核的环境 ,是不是与这个有关 哪位给解释下过程 |
|