-
C (
http://www.daniweb.com/forums/forum118.html)
| rasakse | Feb 4th, 2007 3:53 am | |
| 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 |
| Ravalon | Feb 4th, 2007 10:28 am | |
| Re: c coding on linux Quote: Originally Posted by rasakse (Post 310526) 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? :) |
| John A | Feb 4th, 2007 7:06 pm | |
| Re: c coding on linux 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. |
| All times are GMT -4. The time now is 2:07 pm. | |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC