0

someone please help me on how to run this coding using knoppix linux.. using c language.. i really need help.. i want to know.. what is the output.. this is the coding :-

int main()
{
       Pid_t pid;
       /* fork another process */
       pid=fork();
   
       if (pid<0)
       {
              /* error occured */
              fprintf (stderr,"fork failed");
              exit(-1);
       }
       else if (pid==0)
       {
              /* child process */
              execlp("/bin/ls","ls",NULL);
       }
       else 
       {
              /* parent process */
              /* parent will wait for child to complete */
              wait (NULL);
              printf ("Child Complete");
              exit(0);
       }
}

-please, i need your help

3
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by John A
0

someone please help me on how to run this coding using knoppix linux.. using c language.. i really need help.. i want to know.. what is the output.. this is the coding :-

int main()
{
       Pid_t pid;
       /* fork another process */
       pid=fork();
   
       if (pid<0)
       {
              /* error occured */
              fprintf (stderr,"fork failed");
              exit(-1);
       }
       else if (pid==0)
       {
              /* child process */
              execlp("/bin/ls","ls",NULL);
       }
       else 
       {
              /* parent process */
              /* parent will wait for child to complete */
              wait (NULL);
              printf ("Child Complete");
              exit(0);
       }
}

-please, i need your help

What happens when you run it? :)

0

It probably will, although you'll need the lines

#include <sys/types.h>
#include <unistd.h>

at the top of your program to have the slightest chance of compiling it.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.