Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > problem of wait()

Reply
Thread Tools

problem of wait()

 
 
Richard Tobin
Guest
Posts: n/a
 
      06-25-2007
In article <. com>,
Ravi <> wrote:

> int pid = fork();


You want a unix newsgroup for this.

>Can you please explain why exclusion of the *ed statement changes the
>output of the program


And it would be helpful to tell people what the change is. If you want
people to help you, don't make them do unnecessary work.

-- Richard



--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
 
Reply With Quote
 
 
 
 
Ravi
Guest
Posts: n/a
 
      06-25-2007
#include <stdio.h>
main()
{
int pid = fork();
if(pid==0) {
printf("1:the child about to become a zombie.pid = %d",getpid());
} else {
printf("\n0.0arent here. pid = %d",getpid());
getchar(); // inclusion of this line changes the output. why?-----*
pid=fork();
if (pid==0) {
printf("\n2:the child about to become a zombie. pid =
%d",getpid());
} else {
printf("\n0.1arent here. pid = %d",getpid());
printf("\n0.2:now look into process table");
getchar();
}
}
}


Can you please explain why exclusion of the *ed statement changes the
output of the program

 
Reply With Quote
 
 
 
 
Lew Pitcher
Guest
Posts: n/a
 
      06-25-2007
On Jun 25, 11:36 am, Ravi <ra.ravi....@gmail.com> wrote:
> #include <stdio.h>
> main()
> {
> int pid = fork();
> if(pid==0) {
> printf("1:the child about to become a zombie.pid = %d",getpid());
> } else {
> printf("\n0.0arent here. pid = %d",getpid());
> getchar(); // inclusion of this line changes the output. why?-----*
> pid=fork();
> if (pid==0) {
> printf("\n2:the child about to become a zombie. pid =
> %d",getpid());
> } else {
> printf("\n0.1arent here. pid = %d",getpid());
> printf("\n0.2:now look into process table");
> getchar();
> }
> }
>
> }
>
> Can you please explain why exclusion of the *ed statement changes the
> output of the program


Sorry, but no, we can't.

First off, you use a function (fork()) that is not part of the C
language. Likely, you got this function from someplace else (my guess
is a Unix system function), and while /you/ may know what it does, we
don't.

Secondly, even if we did know what fork() does (and a great number of
here probably do), we don't know what the output of your program looks
like, in order to explain why a single call to getchar() would change
it.

My suggestion is that you ask your question (with more details) in a
forum that knows about C programming and the fork() function.


 
Reply With Quote
 
Default User
Guest
Posts: n/a
 
      06-25-2007
Ravi wrote:

> #include <stdio.h>
> main()
> {
> int pid = fork();
> if(pid==0) {
> printf("1:the child about to become a zombie.pid = %d",getpid());
> } else {
> printf("\n0.0arent here. pid = %d",getpid());
> getchar(); // inclusion of this line changes the output. why?-----*
> pid=fork();
> if (pid==0) {
> printf("\n2:the child about to become a zombie. pid =
> %d",getpid());
> } else {
> printf("\n0.1arent here. pid = %d",getpid());
> printf("\n0.2:now look into process table");
> getchar();
> }
> }
> }


Try comp.unix.programmer.

> Can you please explain why exclusion of the *ed statement changes the
> output of the program



When you do, tell them what the outputs are.




Brian
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem problem problem :( Need Help Mike ASP General 2 05-11-2004 08:36 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57