mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Alexander Scherbatiy <alexander.scherbatiy@bell-sw.com>
To: musl@lists.openwall.com, Rich Felker <dalias@libc.org>
Subject: Re: [musl] fopen with "e" mode to close file descriptor in exec... functions
Date: Mon, 10 Feb 2020 12:57:00 +0300	[thread overview]
Message-ID: <CA+dhEd5F3qWFikiABS1QNqY5Dr+YDNVkmcSD4-DuerWsELk4dw@mail.gmail.com> (raw)
In-Reply-To: <20200208161908.GN1663@brightrain.aerifal.cx>

Just a question about lsof options. On Ubuntu "lsof -q" gives: "lsof:
illegal option character: q".
Shouldn't busybox "lsof -p" give the similar error message?

Is there an open request to support "lsof -p" option in busybox?

Thanks,
Alexandr.

On 08.02.2020 19:19, Rich Felker wrote:
> On Sat, Feb 08, 2020 at 10:45:10AM +0300, Alexander Scherbatiy wrote:
>> Below are steps to reproduce it in docker, logs from docker and strace log.
>>
>>> docker run --rm -it alpine:3.11.3 ash
>>> apk add gcc
>>> apk add libc-dev
>> Copy the posix_spawn_sample.c code below (note it uses "ash" in 'char
>> *argv[] = {"ash", ,,,}' for posix_spawn on Alpine Linux )
>>
>>> gcc -o posix_spawn_sample posix_spawn_sample.c
>>> ./posix_spawn_sample
>> --- output ---
>> / # ./posix_spawn_sample
>> Child pid: 17
>> PID=17
>> 1 /bin/busybox /dev/pts/0
>> 1 /bin/busybox /dev/pts/0
>> 1 /bin/busybox /dev/pts/0
>> 1 /bin/busybox /dev/tty
>> 16 /posix_spawn_sample /dev/pts/0
>> 16 /posix_spawn_sample /dev/pts/0
>> 16 /posix_spawn_sample /dev/pts/0
>> 16 /posix_spawn_sample /test.log
>> ----------------
>>
>> Note that "test.log" file is listed by "lsof -p PID" command.
> It's listed as being owned by pid 16, the parent, not pid 17, the
> child. That's expected. At first I didn't understand why lsof -p is
> showing these additional pids (parent and init) in addition to the
> requested one. But it seems since you're using Docker those are the
> *only* pids running, and you just hit the issue that busybox lsof does
> not support -p (or any options at all) and always lists all open files
> for all processes.
>
> It would be a lot better to have your test do like I suggested and ls
> -l /proc/$$/fd rather than running lsof. Then you will very clearly
> that the log file is not open. Or even run an interactive shell as the
> child so you can explore /proc yourself from it.
>
> Rich

  reply	other threads:[~2020-02-10  9:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-07 18:22 Alexander Scherbatiy
2020-02-07 21:03 ` Rich Felker
2020-02-08  7:45   ` Alexander Scherbatiy
2020-02-08 16:19     ` Rich Felker
2020-02-10  9:57       ` Alexander Scherbatiy [this message]
2020-02-10 14:56         ` Rich Felker

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=CA+dhEd5F3qWFikiABS1QNqY5Dr+YDNVkmcSD4-DuerWsELk4dw@mail.gmail.com \
    --to=alexander.scherbatiy@bell-sw.com \
    --cc=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).