Pages

Tuesday 5 February 2019

exec() System call program - ubuntu

/* program for execute system call  */
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>  // for datatypes
#include<sys/types.h> // for standard symbolic constants & types
int main(int argc, char *argv[])
{
    int ret;
    printf("\n the pid is %d \n",getpid());
    ret=execl("/bin/ls","ls","-l",NULL);  // path the command (ls -l )
    printf("failed process is %d",ret);
return 0;
}

output:

No comments:

Post a Comment