Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #262589 > unrolled thread

Re: 12.2: fork() causing getline() to repeat stdin endlessly

Started by"Thomas Schmitt" <scdbackup@gmx.net>
First post2023-10-23 10:50 +0200
Last post2023-10-24 05:00 +0200
Articles 4 on this page of 24 — 9 participants

Back to article view | Back to linux.debian.user

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: 12.2: fork() causing getline() to repeat stdin endlessly "Thomas Schmitt" <scdbackup@gmx.net> - 2023-10-23 10:50 +0200
    Re: 12.2: fork() causing getline() to repeat stdin endlessly "Thomas Schmitt" <scdbackup@gmx.net> - 2023-10-23 11:20 +0200
      Re: 12.2: fork() causing getline() to repeat stdin endlessly Greg Wooledge <greg@wooledge.org> - 2023-10-23 15:40 +0200
        Re: 12.2: fork() causing getline() to repeat stdin endlessly jleonard@slimy.com (Jon Leonard) - 2023-10-23 16:20 +0200
          Re: 12.2: fork() causing getline() to repeat stdin endlessly tom kronmiller <twk.personal@gmail.com> - 2023-10-23 16:40 +0200
            Re: 12.2: fork() causing getline() to repeat stdin endlessly Greg Wooledge <greg@wooledge.org> - 2023-10-23 17:20 +0200
          Re: 12.2: fork() causing getline() to repeat stdin endlessly gene heskett <gheskett@shentel.net> - 2023-10-23 18:40 +0200
            Re: 12.2: fork() causing getline() to repeat stdin endlessly <tomas@tuxteam.de> - 2023-10-23 20:10 +0200
      Re: 12.2: fork() causing getline() to repeat stdin endlessly tom kronmiller <twk.personal@gmail.com> - 2023-10-23 21:50 +0200
        Re: 12.2: fork() causing getline() to repeat stdin endlessly "Thomas Schmitt" <scdbackup@gmx.net> - 2023-10-23 22:20 +0200
          Re: 12.2: fork() causing getline() to repeat stdin endlessly Greg Wooledge <greg@wooledge.org> - 2023-10-23 22:30 +0200
            Re: 12.2: fork() causing getline() to repeat stdin endlessly "Thomas Schmitt" <scdbackup@gmx.net> - 2023-10-23 22:50 +0200
              Re: 12.2: fork() causing getline() to repeat stdin endlessly Greg Wooledge <greg@wooledge.org> - 2023-10-23 23:00 +0200
          Re: 12.2: fork() causing getline() to repeat stdin endlessly tom kronmiller <twk.personal@gmail.com> - 2023-10-24 07:20 +0200
            Re: 12.2: fork() causing getline() to repeat stdin endlessly Max Nikulin <manikulin@gmail.com> - 2023-10-24 18:10 +0200
              Re: 12.2: fork() causing getline() to repeat stdin endlessly Greg Wooledge <greg@wooledge.org> - 2023-10-24 21:30 +0200
                Re: 12.2: fork() causing getline() to repeat stdin endlessly conover@panix.com (John Conover) - 2023-10-25 01:00 +0200
                Re: 12.2: fork() causing getline() to repeat stdin endlessly jleonard@slimy.com (Jon Leonard) - 2023-10-25 04:20 +0200
                Re: 12.2: fork() causing getline() to repeat stdin endlessly Max Nikulin <manikulin@gmail.com> - 2023-10-25 04:40 +0200
                Re: 12.2: fork() causing getline() to repeat stdin endlessly <tomas@tuxteam.de> - 2023-10-25 06:30 +0200
              Re: 12.2: fork() causing getline() to repeat stdin endlessly tom kronmiller <twk.personal@gmail.com> - 2023-10-25 07:40 +0200
                Re: 12.2: fork() causing getline() to repeat stdin endlessly tom kronmiller <twk.personal@gmail.com> - 2023-10-25 08:00 +0200
    Re: 12.2: fork() causing getline() to repeat stdin endlessly Max Nikulin <manikulin@gmail.com> - 2023-10-23 18:30 +0200
      Re: 12.2: fork() causing getline() to repeat stdin endlessly Stefan Monnier <monnier@iro.umontreal.ca> - 2023-10-24 05:00 +0200

Page 2 of 2 — ← Prev page 1 [2]


#262701

Fromtom kronmiller <twk.personal@gmail.com>
Date2023-10-25 07:40 +0200
Message-ID<HsEMx-GmD-3@gated-at.bofh.it>
In reply to#262674

[Multipart message — attachments visible in raw view] — view raw

On Tue, Oct 24, 2023 at 12:02 PM Max Nikulin <manikulin@gmail.com> wrote:

> On 24/10/2023 12:18, tom kronmiller wrote:
> > so I unbuffered stdin and that seemed to make it happy.
> It might be performance killer. Even fflush(NULL) before fork() may be
> better.
>

In the real program in question, it hardly matters.  It is very heavily
compute-bound on inputs which are small.  But flushing() the files seems a
better idea in general than unbuffering, so I changed it.  (Still works.)

[toc] | [prev] | [next] | [standalone]


#262703

Fromtom kronmiller <twk.personal@gmail.com>
Date2023-10-25 08:00 +0200
Message-ID<HsF5T-Grg-1@gated-at.bofh.it>
In reply to#262701

[Multipart message — attachments visible in raw view] — view raw

On Wed, Oct 25, 2023 at 1:35 AM tom kronmiller wrote:

> On Tue, Oct 24, 2023 at 12:02 PM Max Nikulin wrote:
>
>> On 24/10/2023 12:18, tom kronmiller wrote:
>> > so I unbuffered stdin and that seemed to make it happy.
>> It might be performance killer. Even fflush(NULL) before fork() may be
>> better.
>>
> In the real program in question, it hardly matters.  It is very heavily
> compute-bound on inputs which are small.  But flushing() the files seems a
> better idea in general than unbuffering, so I changed it.  (Still works.)
>

By the way, one last way to get in trouble: fflush(NULL) only flushes
output files, so an explicit fflush(stdin) is still needed.
"If the stream argument is NULL, fflush() flushes all open *output*
streams" per the man page on my system.

[toc] | [prev] | [next] | [standalone]


#262615

FromMax Nikulin <manikulin@gmail.com>
Date2023-10-23 18:30 +0200
Message-ID<Hs5Yt-jHU-3@gated-at.bofh.it>
In reply to#262589
On 23/10/2023 15:45, Thomas Schmitt wrote:
> - Why no "fork() = " after the lines which show their number for the 
> first time ?

https://stackoverflow.com/questions/2530663/printf-anomaly-after-fork

fork clones stdout buffer and child exit flushes its content.

[toc] | [prev] | [next] | [standalone]


#262640

FromStefan Monnier <monnier@iro.umontreal.ca>
Date2023-10-24 05:00 +0200
Message-ID<HsfO9-q51-1@gated-at.bofh.it>
In reply to#262615
Max Nikulin [2023-10-23 23:25:33] wrote:
> On 23/10/2023 15:45, Thomas Schmitt wrote:
>> - Why no "fork() = " after the lines which show their number for the first
>> time ?
> https://stackoverflow.com/questions/2530663/printf-anomaly-after-fork
> fork clones stdout buffer and child exit flushes its content.

That makes sense: I though it's odd that `fork` would touch those file
descriptors (or worse the stdio buffers), but indeed the problem could
very well come from `exit`.


        Stefan

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | linux.debian.user


csiph-web