public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Paul Wise <pabs3@bonedaddy.net>
Cc: Libc-help <libc-help@sourceware.org>
Subject: Re: is this a bug in glibc or readpst?
Date: Fri, 02 Dec 2022 18:37:13 +0100	[thread overview]
Message-ID: <87ilitpv06.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <d64838c66a1e7a4f9ea849d41929b6edbec5567f.camel@bonedaddy.net> (Paul Wise's message of "Thu, 24 Nov 2022 08:06:41 +0800")

* Paul Wise:

> On Wed, 2022-11-23 at 09:57 +0100, Florian Weimer via Libc-help wrote:
>
>> Fork still shares the underlying file description.  It only duplicates
>> the descriptors.  If the subprocess changes the file pointer back to 0,
>> it will affect the original process, too.  This is just how file
>> descriptors work.
>> 
>> Could this explain the issue?
>
> That does sound like what the symptoms would indicate.
>
> However it doesn't seem to fit, because the first thing the child
> process does is call freopen(), which should in theory close the
> descriptor and then create a new file descriptor and file description?
>
> On the other hand, the fact that using fclose()+fopen() instead of
> freopen() does seem to fix the problem, seems to indicate that
> freopen() is not actually successfully closing the descriptor and
> thus the file pointer is shared between processes?

Could you run it under strace -k, with debuginfo?  Hopefully that will
shed some light on the problem.

Thanks,
Florian


  reply	other threads:[~2022-12-02 17:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-23  2:02 Paul Wise
2022-11-23  8:57 ` Florian Weimer
2022-11-24  0:06   ` Paul Wise
2022-12-02 17:37     ` Florian Weimer [this message]
2023-08-06  6:07       ` Paul Wise
2023-08-07  8:59         ` Florian Weimer
2023-08-07 11:00           ` Paul Wise
2023-08-07 11:46             ` Florian Weimer
2023-08-07 11:58               ` Paul Wise

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ilitpv06.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=libc-help@sourceware.org \
    --cc=pabs3@bonedaddy.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).