
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <assert.h>


int main(int argc, char *argv[]){
    int n = atoll(argv[1]);
    int i,sum=0;
    int fds[2];
    int test;

    pipe(fds);

    if(!fork()){
       /* int a;
        test = close(fds[1]); assert(test==0);
        while(read(0,&a,sizeof(int))){
            printf("Tal: %d\n",a);
        }
        test = close(fds[0]); assert(test==0);*/
        sleep(1);
        exit(0);
    }
    system("ps -o pid,ppid,pgid,sess,comm");
    for(i=0;i<n;i++){
        if(!fork()){
            close(1);
            execlp
            sleep(1);
            exit(0);
        }
        system("ps -o pid,ppid,pgid,sess,comm");
        wait(0);
    }
    test = close(fds[0]); assert(test==0);
    test = close(fds[1]); assert(test==0);
    wait(0);
    system("ps -o pid,ppid,pgid,sess,comm");

}
