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


Groups > linux.debian.user > #262583

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

From Stefan Monnier <monnier@iro.umontreal.ca>
Newsgroups linux.debian.user
Subject Re: 12.2: fork() causing getline() to repeat stdin endlessly
Date 2023-10-23 05:30 +0200
Message-ID <HrTND-bMD-1@gated-at.bofh.it> (permalink)
References <HrTkB-bne-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


> I have a small program (extracted from a big program) which reads and
> prints input lines using a loop of getline() calls.  The real input lines
> are all expected to be 52 characters long (+1 for the newline => 53),
> that's what my example data for the small program looks like.  If there is
> no fork() in the loop, it works fine.  Inside the loop if I do a fork() of
> a child which immediately exits (no exec) and waitpid() for it, then the
> program loops forever repeating the beginning portion of stdin.
>
> I have no idea what package to report the problem against, though it
> doesn't seem to be gcc as I have tried both gcc12 (which comes with debian)
> and gcc13 (which I installed manually).

My crystal ball says the most likely culprits are (in order):
- your code.
- POSIX.
- glibc.
- the kernel.


        Stefan

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

12.2: fork() causing getline() to repeat stdin endlessly tom kronmiller <twk.personal@gmail.com> - 2023-10-23 05:00 +0200
  Re: 12.2: fork() causing getline() to repeat stdin endlessly Stefan Monnier <monnier@iro.umontreal.ca> - 2023-10-23 05:30 +0200
  Re: 12.2: fork() causing getline() to repeat stdin endlessly Greg Wooledge <greg@wooledge.org> - 2023-10-23 05:40 +0200

csiph-web