父进程C / C ++,LINUX中的子进程数 [英] Number of child processes in parent process C/C++, LINUX

查看:253
本文介绍了父进程C / C ++,LINUX中的子进程数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Linux中使用C / C ++编程。我有一个问题,我试图找到一个函数或某事为了获得父进程中的子进程数。

I am programming in Linux using C/C++. I have a problem, i am trying to find a function or something in order to get number of child processes in parent process.

帮助我
感谢

推荐答案

我不知道POSIX是否定义了一个函数,但你可以自己计算一个全局变量,在父节点上的每个分支后添加1,并在子节点上将其设置为0.

I'm not sure if POSIX defines a function for this, but you could always count them in a global variable yourself, just add 1 after every fork on the parent, and set it to 0 on the child..

这篇关于父进程C / C ++,LINUX中的子进程数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆