Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximum number of child process in Unix

I have a question going in my mind. I just want to know what is the maximum limit on the number of child process when it is created by a process by using fork() system call? I am using UBUNTU OS (12.04) with kernel 3.2.0-45-generic.

like image 426
Prak Avatar asked Jul 23 '13 13:07

Prak


People also ask

How many child processes can a process have?

A parent process may have multiple child processes, but a child process only one parent process. On the success of a fork() system call: The Process ID (PID) of the child process is returned to the parent process. 0 is returned to the child process.

What is the maximum number of processes?

The kernel. pid_max value of 131072 above means the kernel can execute a maximum of 131,072 processes simultaneously. The vm. max_map_count value of 65530 above is the maximum number of memory map areas a process may have.

What is the max number of processes Linux?

On some Linux distributions (Redhat Enterprise Linux Server/CentOS 6.0 or later), the default maximum number of user processes is set to 1024, which is considerably lower than the same parameter on older distributions (e.g., RHEL/CentOS 5. x).

Can a process have multiple child processes?

Using some conditions we can generate as many child process as needed.


1 Answers

Programmatically,

#include <stdio.h>
#include <sys/resource.h>

int main()
{
    struct rlimit rl;
    getrlimit(RLIMIT_NPROC, &rl);
    printf("%d\n", rl.rlim_cur);
}

where struct rlimit is:

struct rlimit {
    rlim_t rlim_cur;  /* Soft limit */
    rlim_t rlim_max;  /* Hard limit (ceiling for rlim_cur) */
};

From man:

RLIMIT_NPROC

The maximum number of processes (or, more precisely on Linux, threads) that can be created for the real user ID of the calling process. Upon encountering this limit, fork(2) fails with the error EAGAIN.

like image 62
mohit Avatar answered Sep 28 '22 09:09

mohit