c - Process ID is always 0 in linux, Is it valid? -
my program finds pid in linux. it’s returning 0. supposed this? used gcc
. valid? when process ids without 0? here code.
#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <sys/types.h> int main() { pid_t pid; /* process id */ if ((pid = getpid()) < 0) perror(" unable pid"); else printf(" process id %d", pid); return (0); }
so after compiling program prints in terminal “the process id is: 0”.
Comments
Post a Comment