conradin
August 6th, 2013, 09:35 PM
#include <sys/types.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdlib.h>
#include <unistd.h> //required by execl
#include <stdio.h>
int pid, ppid;
int main()
{
pid=getpid();
printf("PID of this process is: %x\n",pid);
if (fork()==0){
pid=getpid();
ppid=getppid();
printf("I'm in the Replica and my PID is: %x\n",pid);
printf("... About to execute my Program, PID should be the same\n");
printf("... PID of parent process is: %x\n",ppid);
execl("./myprog", NULL);}
pid = waitpid ((pid_t)-1, NULL, WNOHANG);
return 0;
}
line with: execl("./myprog", NULL);}
gets these warnings?
FEW.c:21:3: warning: null argument where non-null required (argument 2) [-Wnonnull]
FEW.c:21:3: warning: not enough variable arguments to fit a sentinel [-Wformat]
I have read the man page for execl But.. I dont know what to put in the place of null. I am not trying to pass arguments to myprog (located in the same directory).
what should I put in the place of NULL? how do i fix these warnings?
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdlib.h>
#include <unistd.h> //required by execl
#include <stdio.h>
int pid, ppid;
int main()
{
pid=getpid();
printf("PID of this process is: %x\n",pid);
if (fork()==0){
pid=getpid();
ppid=getppid();
printf("I'm in the Replica and my PID is: %x\n",pid);
printf("... About to execute my Program, PID should be the same\n");
printf("... PID of parent process is: %x\n",ppid);
execl("./myprog", NULL);}
pid = waitpid ((pid_t)-1, NULL, WNOHANG);
return 0;
}
line with: execl("./myprog", NULL);}
gets these warnings?
FEW.c:21:3: warning: null argument where non-null required (argument 2) [-Wnonnull]
FEW.c:21:3: warning: not enough variable arguments to fit a sentinel [-Wformat]
I have read the man page for execl But.. I dont know what to put in the place of null. I am not trying to pass arguments to myprog (located in the same directory).
what should I put in the place of NULL? how do i fix these warnings?