From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.2 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by inbox.vuxu.org (OpenSMTPD) with SMTP id 8a1e6c51 for ; Mon, 10 Feb 2020 09:57:26 +0000 (UTC) Received: (qmail 7707 invoked by uid 550); 10 Feb 2020 09:57:23 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 7689 invoked from network); 10 Feb 2020 09:57:23 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bell-sw-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=5I4UJL8r5HBPYulbxv6UXLrWwaXnf6o59J4QFaq/GBU=; b=dOO7JpJm43xq+3Q6HYagkivYFgKQ3Lti0Zso0jNz2ZFqOm4zAGJLwCZzPLqwE3d+dz d/+QN8gHTjB/QgsV3FrgtDaft1OIko62zvam2x3nrAMU8uJVs5I2XuJJcKq1jtpgPLeg bBAThhKU/7b+ljUVbil/UClB2sGvU5g5H5B6l6K9NQXB6uMtz2ku+Lb8wp6c9skBTwdL Z2NlKMVdlQeKvJ4mHcXV/Tssa1opaJDLUKD6MH5H+MHdArq5nvjlhXJ7xglMQdj1r83J 5BXXrKOVMQa2+VMUOMxiK3s55rLzAAl2fhG2mQhr+lBidAEjVrVkT4fT7HChzeB9QTHK 8H5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=5I4UJL8r5HBPYulbxv6UXLrWwaXnf6o59J4QFaq/GBU=; b=sV9SRbtMvCEBj0yVXGsM0Vf0vrF/Hws8ALCrsRhg2M7c9VEMY2Zy3snmiMUPqeuIiA TMtLLNWH4YzylyTkl/QdvyGji6N0sOJX7CCRe1kIrMt/7uC5OYD3ODQQG7EA/mFHkFEc JLZ3a0mkfjMMA1Xvz5m+f9Ay3hUBXflLxOBRAwfThUu/gmHrkJ0YNLuEh76hOn9NLEwl KVcyifRW0d7FjS2uHhsZfHN6u5sEKiloEWqMexpBXzf7i2Md6lrwClstbIGLT5rY/xbS myZwaSLtqr7ZNXFnr2MN4CBnv95RSGJYg/U9MZmj8yB8GgIn6Cp7oRPOweGpmf5Rnsy+ em+g== X-Gm-Message-State: APjAAAVci/RxPzGxs3nxOdrayCM4mytgqakgpjrhgGGaegNL8dQsp1Fs QWcmYpjfDWfd96+WlOZ6ytNvM36PQ8eRzQbJk2AAjnn3 X-Google-Smtp-Source: APXvYqzsELIcmoFrGFVXNvHs7XSGRK+si6DX+8DtwfD6LXH1I6KelfKUjj6S08qOa55XTnqBGoHYyEKDIG+MMsbtjzc= X-Received: by 2002:ae9:ed4a:: with SMTP id c71mr523592qkg.501.1581328631288; Mon, 10 Feb 2020 01:57:11 -0800 (PST) MIME-Version: 1.0 References: <20200207210331.GK1663@brightrain.aerifal.cx> <20200208161908.GN1663@brightrain.aerifal.cx> In-Reply-To: <20200208161908.GN1663@brightrain.aerifal.cx> From: Alexander Scherbatiy Date: Mon, 10 Feb 2020 12:57:00 +0300 Message-ID: To: musl@lists.openwall.com, Rich Felker Content-Type: text/plain; charset="UTF-8" Subject: Re: [musl] fopen with "e" mode to close file descriptor in exec... functions 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