Take the 2-minute tour ×  I have this code:  #include <stdio.h>
#include <unistd.h> #include <semaphore.h> #include <sys/shm.h>
#include <sys/stat.h> #include <sys/types.h>  int main(){
int segment_n;     int segment_sem;     int *shared_n;     sem_t
*shared_sem;     int pid_int;     pid_t pid;      segment_n =
shmget(IPC_PRIVATE, sizeof(int), S_IRUSR | S_IWUSR);
segment_sem = shmget(IPC_PRIVATE, sizeof(sem_t), S_IRUSR |
S_IWUSR);     shared_n = (int *)shmat(segment_n, NULL, 0);
shared_sem = (sem_t *)shmat(segment_sem, NULL, 0);
sem_init(shared_sem, 0, 0);      scanf("%d", shared_n);      pid
= fork();     if(pid < 0){         return 1;     } else if(pid
== 0){     pid_int = (int)getpid();     if(pid_int > *shared_n){
*shared_n = 1;         }else if(pid_int == *shared_n){
*shared_n = 0;         } else {             *shared_n = -1;
return 0;     } else {         printf("returns: %d\n",
*shared_n);         return 0;     return 0;  The program creates
a child process