954,198 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

c coding on linux

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

rasakse
Newbie Poster
1 post since Feb 2007
Reputation Points: 10
Solved Threads: 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? :)

Ravalon
Posting Whiz in Training
213 posts since Dec 2006
Reputation Points: 84
Solved Threads: 15
 

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.

John A
Vampirical Lurker
Team Colleague
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You