Search
 
SCRIPT & CODE EXAMPLE
 

C

Creating a process in C

julien@ubuntu:~/c/shell$ cat fork.c
#include <stdio.h>
#include <unistd.h>

/**
 * main - fork example
 *
 * Return: Always 0.
 */
int main(void)
{
    pid_t my_pid;
    pid_t pid;

    printf("Before fork
");
    pid = fork();
    if (pid == -1)
    {
        perror("Error:");
        return (1);
    }
    printf("After fork
");
    my_pid = getpid();
    printf("My pid is %u
", my_pid);
    return (0);
}
julien@ubuntu:~/c/shell$ ./fork 
Before fork
After fork
My pid is 4819
julien@ubuntu:~/c/shell$ After fork
My pid is 4820
Comment

PREVIOUS NEXT
Code Example
C :: how to open jupyter notebook in local disk D 
C :: c printf to string 
C :: see if two strings are equal in C 
C :: windeployqt example 
C :: Prime Number Check Program in C 
C :: successeur d’un entier donné 
C :: #![feature]` may not be used on the // stable release channel 
C :: fast inverse square root explained 
C :: search array element in c 
C :: exclamation mark in c 
C :: arduino millis() 
C :: printf type format 
C :: c fork wait for child 
C :: multiplicationin c 
C :: what is system function in c 
C :: function for calculate the average and standard deviation of table 
C :: limit axis in one direction plt 
C :: Firebase Connecting with ESP8266 
C :: c fopen 
C :: mpi example 
C :: identifier bool is undefined in c 
C :: c language string 
C :: sort names in array in c 
C :: array of strings in c 
C :: print an int c 
C :: how to change file permissions in C language 
C :: c structure with pointer 
C :: time include c 
C :: commenting in c 
C :: how to input a string into a char array cpp 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =