Learn linux process, creating a process, states of linux process, zombie process, creating process using fork system call, getting process ID(PID) and group info using system calls.
A process is an active program i.e. a program that is under execution.
Let's write the following small program square.c and create an executable SQUARE for it.
#include "stdio.h"
void main()
{
int num;
start:
printf("Enter a number\n");
scanf("%d",&num);
while(num < 10)
{
printf("Square of your number:%d\n",num * num);
goto start;
}
}
Output:$ gcc square.c -o SQUARE $ ./SQUARE Enter a number 3 Square of your number:9 Enter a number 5 Square of your number:25 Enter a number
Let's open another console and execute ps -aux command to observe the process we have created.
$ ps -aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.6 26936 5940 ? Ss 01:46 0:02 /sbin/init splash pi 2063 0.0 0.0 1812 328 pts/0 S+ 05:09 0:00 ./SQUARE pi 2115 0.0 0.3 7736 2868 pts/1 R+ 05:13 0:00 ps -aux $
When we executed the ps -aux command we got all processes information detail. I have intentionally removed the other processes and kept few lines for your observation
Share | Tweet |
---|
Search more C examples |
Search more C MCQs |
Linux OS Internals |
Linux OS Commands |
Linux Processes and Threads |
Linux IPC Mechanisms |
Git Version Control |
Series completion |
LCM and HCF of numbers |
Time and Distance |
Microcontrollers, Tools & Peripherals |
I2C Protocol & Applications |
SPI Protocol & Applications |
UART Protocol & Applications |