Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

To get process ID

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

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

    my_pid = getpid();
    printf("%u
", my_pid);
    return (0);
}
julien@ubuntu:~/c/shell$ gcc -Wall -Werror -pedantic pid.c -o mypid && ./mypid
3237
julien@ubuntu:~/c/shell$ ./mypid 
3238
julien@ubuntu:~/c/shell$ ./mypid 
3239
julien@ubuntu:~/c/shell$
Source by alx-intranet.hbtn.io #
 
PREVIOUS NEXT
Tagged: #To #process #ID
ADD COMMENT
Topic
Name
6+3 =