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

Recommended Answers

All 2 Replies

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? :)

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.