fork call

  • Follow


hi all ,

I am wondering why a call to  fork fails to print some statements  in
the child.

It works fine when  terminal is defualt for O/p .

in case  i try  redirection it fails to redirect all the print
statements . 

Any clue ?

Anshul

0
Reply anshul1806 (2) 5/23/2006 5:28:52 PM


anshul1806@gmail.com wrote On 05/23/06 13:28,:
> hi all ,
> 
> I am wondering why a call to  fork fails to print some statements  in
> the child.
> 
> It works fine when  terminal is defualt for O/p .
> 
> in case  i try  redirection it fails to redirect all the print
> statements . 

    Try a "redirection" to an appropriate newsgroup,
possibly comp.unix.programmer.  Follow-ups set.

<off-topic>

    And when you go there, for goodness' sake learn to
write an accurate problem report!  For the record, fork()
doesn't print anything, isn't expected to print anything,
and doesn't do anything about I/O redirection.  You are
therefore writing about the things that *don't* pertain
to your problem, which isn't the best way to get help in
reaching a solution.

</off-topic>

-- 
Eric.Sosman@sun.com

0
Reply Eric.Sosman (4228) 5/23/2006 5:38:09 PM


anshul1806@gmail.com wrote:
> hi all ,
>
> I am wondering why a call to  fork fails to print some statements  in
> the child.
>
> It works fine when  terminal is defualt for O/p .
>
> in case  i try  redirection it fails to redirect all the print
> statements .
> 
> Any clue ?

Wrong group, try comp.unix.programmer.

Robert Gamble

0
Reply rgamble99 (794) 5/23/2006 5:39:22 PM

>I am wondering why a call to  fork fails to print some statements  in
>the child.

fork() by itself does not print anything.

How did you redirect output?  You should call fflush(NULL) or
fflush() your output streams before fork() to avoid dupliate
output held in buffers.  Note that output to a file may be
buffered, so you may need to call fflush() to see output
if the program is waiting for something.

>It works fine when  terminal is defualt for O/p .

Octal/pointers?

>in case  i try  redirection it fails to redirect all the print
>statements . 

Did you redirect stdout *and* stderr?

>Any clue ?

The problem is in line 42 of the code you didn't include.

					Gordon L. Burditt
0
Reply gordonb.hbxrl (1) 5/23/2006 5:44:54 PM

gordonb.hbxrl@burditt.org (Gordon Burditt) writes:
>>I am wondering why a call to  fork fails to print some statements  in
>>the child.
>
> fork() by itself does not print anything.

The question was posted by anshul1806@gmail.com.  Gordon, as usual,
refuses to provide attributions, so I'll do it for him.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center             <*>  <http://users.sdsc.edu/~kst>
We must do something.  This is something.  Therefore, we must do this.
0
Reply kst-u (21474) 5/23/2006 7:27:54 PM

Keith Thompson wrote:
> gordonb.hbxrl@burditt.org (Gordon Burditt) writes:
> >>I am wondering why a call to  fork fails to print some statements  in
> >>the child.
> >
> > fork() by itself does not print anything.
>
> The question was posted by anshul1806@gmail.com.  Gordon, as usual,
> refuses to provide attributions, so I'll do it for him.

Err, don't you think everyone except those using the primitivest of
newsreaders and very poorly retentive Usenet providers would be able to
read the posts up-thread and deduce the attributions?

Do you really plan on supplying attributions to each and every one of
Gordon's posts to this group, let alone whatever he might post
elsewhere on Usenet?

0
Reply santosh.k83 (3969) 5/23/2006 7:35:36 PM

"santosh" <santosh.k83@gmail.com>.
> Keith Thompson wrote:
>> gordonb.hbxrl@burditt.org (Gordon Burditt) writes:

>> >>I am wondering why a call to  fork fails to print some statements  in
>> >>the child.
>> >
>> > fork() by itself does not print anything.
>>
>> The question was posted by anshul1806@gmail.com.  Gordon, as usual,
>> refuses to provide attributions, so I'll do it for him.
>
> Err, don't you think everyone except those using the primitivest of
> newsreaders and very poorly retentive Usenet providers would be able to
> read the posts up-thread and deduce the attributions?
>
> Do you really plan on supplying attributions to each and every one of
> Gordon's posts to this group, let alone whatever he might post
> elsewhere on Usenet?

Superlative for primitive is 'most primitive'.  The regulars, meaning guys 
like Keith Thompson who consistently provide quality posts and probably plow 
through a hundred a day, are finding frustration with many of the posts from 
a standpoint of readability, contnuity and attribution.  joe 


0
Reply grumpy196884 (155) 5/23/2006 8:08:21 PM

"santosh" <santosh.k83@gmail.com> writes:
> Keith Thompson wrote:
>> gordonb.hbxrl@burditt.org (Gordon Burditt) writes:
>> >>I am wondering why a call to  fork fails to print some statements  in
>> >>the child.
>> >
>> > fork() by itself does not print anything.
>>
>> The question was posted by anshul1806@gmail.com.  Gordon, as usual,
>> refuses to provide attributions, so I'll do it for him.
>
> Err, don't you think everyone except those using the primitivest of
> newsreaders and very poorly retentive Usenet providers would be able to
> read the posts up-thread and deduce the attributions?

I can jump to the parent article -- *if* it happens to be on my
server.  (That's how I figured out who posted the question.)  To do
so, I have to interrupt my reading of the current article, and getting
back to the followup article can be non-trivial.

I see that you include attribution lines in your posts.  If it's so
easy to deduce attributions, why do you bother?

The point is that I shouldn't have to do this just to find out who
posted the previous article.  That's what attribution lines are for.
Gordon deliberately deletes attribution lines, for reasons that are
based on some astonishing claims he's made.  This was recently
discussed here at length, but Gordon dropped out of the discussion had
has not, in my opinion, given adequate justification for his behavior.

> Do you really plan on supplying attributions to each and every one of
> Gordon's posts to this group, let alone whatever he might post
> elsewhere on Usenet?

I'm making a point about Gordon's deliberate failure to follow Usenet
norms.  I haven't decided how or whether I'll do so in the future.  Do
you plain on complaining every time I raise this point?

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center             <*>  <http://users.sdsc.edu/~kst>
We must do something.  This is something.  Therefore, we must do this.
0
Reply kst-u (21474) 5/23/2006 8:13:34 PM

santosh wrote:
> Keith Thompson wrote:
>> gordonb.hbxrl@burditt.org (Gordon Burditt) writes:
>>>> I am wondering why a call to  fork fails to print some statements  in
>>>> the child.
>>> fork() by itself does not print anything.
>> The question was posted by anshul1806@gmail.com.  Gordon, as usual,
>> refuses to provide attributions, so I'll do it for him.
> 
> Err, don't you think everyone except those using the primitivest of
> newsreaders and very poorly retentive Usenet providers would be able to
> read the posts up-thread and deduce the attributions?
> 
> Do you really plan on supplying attributions to each and every one of
> Gordon's posts to this group, let alone whatever he might post
> elsewhere on Usenet?
> 
My USENET provider (or its peers) expires messages pretty aggressively. 
  Some upthread messages disappear in a matter of /hours/.  In order to 
make sense of a posting I've often had to look on Google Groups.  As 
long as the poster has not set extended headers to expire archives this 
may work, but it's a hell of a lot more work than simply having people 
properly quote some relevant context.

So, I don't think this gentle reminder is not unwarranted.  Whether such 
  reminders will be terribly successful after several years of a 
never-ending autumn due to AOL (and Prodigy, CompuServ, Delphi, ...), 
WebTV and Google Groups remains to be seen.
0
Reply clvrmnky.invalid (895) 5/23/2006 8:57:21 PM

anshul1806@gmail.com wrote:
> hi all ,
> 
> I am wondering why a call to  fork fails to print some statements  in
> the child.
> 
> It works fine when  terminal is defualt for O/p .
> 
> in case  i try  redirection it fails to redirect all the print
> statements . 
> 
> Any clue ?
> 
> Anshul
> 

fork is a system subroutine, not part of C per se, although doubtless
defined by a C program.

-- 
Julian V. Noble
Professor Emeritus of Physics
University of Virginia
0
Reply jvn (707) 5/23/2006 8:57:51 PM

santosh wrote:
> Keith Thompson wrote:
>> gordonb.hbxrl@burditt.org (Gordon Burditt) writes:
>>>> I am wondering why a call to  fork fails to print some statements  in
>>>> the child.
>>> fork() by itself does not print anything.
>> The question was posted by anshul1806@gmail.com.  Gordon, as usual,
>> refuses to provide attributions, so I'll do it for him.
> 
> Err, don't you think everyone except those using the primitivest of
> newsreaders and very poorly retentive Usenet providers would be able to
> read the posts up-thread and deduce the attributions?

So whenever I read one of Gordon's posts I am supposed to change from my 
default view which only shows unread messages, something I don't have to 
do for others posts? Also, what if the post hasn't arrived yet?

> Do you really plan on supplying attributions to each and every one of
> Gordon's posts to this group, let alone whatever he might post
> elsewhere on Usenet?

I doubt it. Keith is making a point, one which I and a number of others 
agree with. Namely that Gordon should be providing the attributions.

Parts of this post are copyright Mark Gordon and may not be reproduced 
without attribution to either Mark Gordon , Flash Gordon, or 
spam@flash-gordon.me.uk.
-- 
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc
0
Reply spam331 (4024) 5/23/2006 9:09:19 PM

anshul1806@gmail.com wrote:
# hi all ,
# 
# I am wondering why a call to  fork fails to print some statements  in
# the child.

fork() doesn't know about stdio, and stdio doesn't know when it's
been forked (up). You have to handle buffer synchronizations in
the parent and child by hand, or not use stdio.

--
SM Ryan http://www.rawbw.com/~wyrmwif/
OOOOOOOOOO! NAVY SEALS!
0
Reply wyrmwif (945) 5/24/2006 2:41:57 AM

SM Ryan <wyrmwif@tango-sierra-oscar-foxtrot-tango.fake.org> writes:
[...]
> fork() doesn't know about stdio, and stdio doesn't know when it's
> been forked (up).

And standard C doesn't know about fork().

Try comp.unix.programmer.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center             <*>  <http://users.sdsc.edu/~kst>
We must do something.  This is something.  Therefore, we must do this.
0
Reply kst-u (21474) 5/24/2006 3:45:57 AM

anshul1806@gmail.com wrote:

> hi all ,
>
> I am wondering why a call to  fork fails to print some statements  in
> the child.
>
> It works fine when  terminal is defualt for O/p .
>
> in case  i try  redirection it fails to redirect all the print
> statements .

There is some problem with the buffering and fork ( ). Read the
Advanced programming in the UNIX environment chapter 3. They have
discussed the problem with the solution to it...


Cheers,
Sandeepksinha



 
> Any clue ?
> 
> Anshul

0
Reply sandeepksinha (13) 5/24/2006 11:13:59 AM

santosh wrote:
> Keith Thompson wrote:
> > gordonb.hbxrl@burditt.org (Gordon Burditt) writes:
>
>>>> I am wondering why a call to  fork fails to print some statements 
>>>> in the child.
>>>
>>> fork() by itself does not print anything.
>>
>> The question was posted by anshul1806@gmail.com.  Gordon, as usual,
>> refuses to provide attributions, so I'll do it for him.
> 
> Err, don't you think everyone except those using the primitivest of
> newsreaders and very poorly retentive Usenet providers would be
> able to read the posts up-thread and deduce the attributions?

Nope.  For example, I periodically clear out all the previously
downloaded information in a newsgroup.  After that there are no
up-thread posts to read.  And you are also assuming that any such
up-thread post did actually arrive, which is not guaranteed.

-- 
"If you want to post a followup via groups.google.com, don't use
 the broken "Reply" link at the bottom of the article.  Click on 
 "show options" at the top of the article, then click on the 
 "Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>


0
Reply cbfalconer (19183) 5/24/2006 11:14:06 AM

CBFalconer wrote:
> 
> santosh wrote:
> > Keith Thompson wrote:
> > > gordonb.hbxrl@burditt.org (Gordon Burditt) writes:
> >
> >>>> I am wondering why a call to  fork fails to print some statements
> >>>> in the child.
> >>>
> >>> fork() by itself does not print anything.
> >>
> >> The question was posted by anshul1806@gmail.com.  Gordon, as usual,
> >> refuses to provide attributions, so I'll do it for him.
> >
> > Err, don't you think everyone except those using the primitivest of
> > newsreaders and very poorly retentive Usenet providers would be
> > able to read the posts up-thread and deduce the attributions?
> 
> Nope.  For example, I periodically clear out all the previously
> downloaded information in a newsgroup.  After that there are no
> up-thread posts to read.  And you are also assuming that any such
> up-thread post did actually arrive, which is not guaranteed.

What are the newsgroups where
fork calls are on topic?

-- 
pete
0
Reply pfiland (6613) 5/24/2006 12:54:17 PM

"pete" <pfiland@mindspring.com> wrote
[snip]
>> >>santosh wrote:

>> >>>> I am wondering why a call to  fork fails to print some statements
>> >>>> in the child.

> What are the newsgroups where
> fork calls are on topic?

Forks, pipes, segments.  These are, for me, three very similar things.  The 
fork is on the left hand side of the plate.  The pipes run overhead.  BTW, I 
liked the link you posted for pipes recently:-)  And segments populate the 
bag of tricks of a geometer.  Clearly the terms have relevance to C on Unix. 
When I hear about them in clc, before they get shooed off, the forks fail, 
the pipes fail, and of course "segmentation fault" is turning into a stock 
epithet.  If I were talking to a person who advocated that these things be 
accomodated within Standard C, I would tell them that they seem to be 
trouble enough for the Unix users.  Are there better reasons?  joe 


0
Reply grumpy196884 (155) 5/24/2006 5:06:13 PM

On 2006-05-24 14:54:17 +0200, pete <pfiland@mindspring.com> said:


>> Nope.  For example, I periodically clear out all the previously
>> downloaded information in a newsgroup.  After that there are no
>> up-thread posts to read.  And you are also assuming that any such
>> up-thread post did actually arrive, which is not guaranteed.
> 
> What are the newsgroups where
> fork calls are on topic?

Unix-related ones.

-- 
Sensei <senseiwa@mac.com>

The optimist thinks this is the best of all possible worlds.
The pessimist fears it is true.      [J. Robert Oppenheimer]

0
Reply senseiwa1 (75) 5/24/2006 5:14:00 PM

In article <44749454$0$14792$4fafbaef@reader4.news.tin.it>,
Sensei  <senseiwa@mac.com> wrote:
>On 2006-05-24 14:54:17 +0200, pete <pfiland@mindspring.com> said:

>> What are the newsgroups where
>> fork calls are on topic?

>Unix-related ones.

And POSIX.1 related ones. You'd probably even get somewhere
with Linux newsgroups, even though Linux is neither Unix nor POSIX.1
(or at least not certified as such.)
-- 
Programming is what happens while you're busy making other plans.
0
Reply roberson2 (8067) 5/24/2006 5:20:18 PM

Joe Smith wrote:
> "pete" <pfiland@mindspring.com> wrote
>> >>santosh wrote:
> [snip]
> 
>>>>>>> I am wondering why a call to  fork fails to print some
>>>>>>> statements in the child.
> 
>> What are the newsgroups where fork calls are on topic?
> 
> Forks, pipes, segments.  These are, for me, three very similar
> things.  The fork is on the left hand side of the plate.  The
> pipes run overhead.  BTW, I liked the link you posted for pipes
> recently:-)  And segments populate the bag of tricks of a geometer. 
> Clearly the terms have relevance to C on Unix. When I hear about
> them in clc, before they get shooed off, the forks fail, the pipes
> fail, and of course "segmentation fault" is turning into a stock
> epithet.  If I were talking to a person who advocated that these
> things be accomodated within Standard C, I would tell them that
> they seem to be trouble enough for the Unix users.  Are there
> better reasons?  joe

My user accessible pipes are all black, and rise straight up.  Not
an elbow in the whole run.  In operation they run quite hot.

-- 
"If you want to post a followup via groups.google.com, don't use
 the broken "Reply" link at the bottom of the article.  Click on 
 "show options" at the top of the article, then click on the 
 "Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell.org/google/>
Also see <http://www.safalra.com/special/googlegroupsreply/>


0
Reply cbfalconer (19183) 5/24/2006 8:58:36 PM

Joe Smith wrote:
> 
> "pete" <pfiland@mindspring.com> wrote
> [snip]
> >> >>santosh wrote:
> 
> >> >>>> I am wondering why a call to
> >> >>>> fork fails to print some statements
> >> >>>> in the child.
> 
> > What are the newsgroups where
> > fork calls are on topic?
> 
> Forks, pipes, segments.  These are, for me,
? three very similar things.  The
> fork is on the left hand side of the plate.
> The pipes run overhead.  BTW, I
> liked the link you posted for pipes recently:-) 

I used to cut threads on pipes in a machine shop.

-- 
pete
0
Reply pfiland (6613) 5/25/2006 12:13:37 AM

"pete" <pfiland@mindspring.com> wrote in message 
news:4474F6B7.2418@mindspring.com...
> Joe Smith wrote:
>>
>> "pete" <pfiland@mindspring.com> wrote
>> [snip]
>> >> >>santosh wrote:
>>
>> >> >>>> I am wondering why a call to
>> >> >>>> fork fails to print some statements
>> >> >>>> in the child.
>>
>> > What are the newsgroups where
>> > fork calls are on topic?
>>
>> Forks, pipes, segments.  These are, for me,
> ? three very similar things.  The
>> fork is on the left hand side of the plate.
>> The pipes run overhead.  BTW, I
>> liked the link you posted for pipes recently:-)
>
> I used to cut threads on pipes in a machine shop.

Hence, your attention to detail.  I'm going bats trying to figure out how 
the pipefitter did whatever he did above me.  I wonder if I can describe it 
abstractly.  The node I observe first has order 4, the second order 3, the 
third order three, the fourth order two, the fifth order two; the sixth may 
either have order two or simply be called NULL .  Every day, as I look, not 
at a blueprint, but the actual installation, I call it impossible.  Then I 
tell myself I just Don't Get It (tm).  joe 


0
Reply grumpy196884 (155) 5/25/2006 1:12:30 AM

21 Replies
26 Views

(page loaded in 0.206 seconds)


Reply: