NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/57894: sh(1): PID obtained with jobs -p is always 0 on NetBSD 10.0 RC



The following reply was made to PR bin/57894; it has been noted by GNATS.

From: Koichi Nakashima <koichi%nksm.name@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: bin/57894: sh(1): PID obtained with jobs -p is always 0 on NetBSD
 10.0 RC
Date: Wed, 31 Jan 2024 08:18:08 +0900

 --0000000000006d318e061031faed
 Content-Type: text/plain; charset="UTF-8"
 Content-Transfer-Encoding: quoted-printable
 
 Thanks for the fixing and the detailed explanation.
 My concern was backward compatibility.
 I probably won't use the jobs command with
 non-interactive shells (unless it is absolutely necessary).
 
 
 2024=E5=B9=B41=E6=9C=8831=E6=97=A5(=E6=B0=B4) 4:05 Robert Elz <kre@munnari.=
 oz.au>:
 
 > The following reply was made to PR bin/57894; it has been noted by GNATS.
 >
 > From: Robert Elz <kre%munnari.OZ.AU@localhost>
 > To: gnats-bugs%netbsd.org@localhost
 > Cc:
 > Subject: Re: bin/57894: sh(1): PID obtained with jobs -p is always 0 on
 > NetBSD 10.0 RC
 > Date: Wed, 31 Jan 2024 02:00:44 +0700
 >
 >      Date:        Tue, 30 Jan 2024 13:35:00 +0000 (UTC)
 >      From:        koichi%nksm.name@localhost
 >      Message-ID:  <20240130133500.967921A923A%mollari.NetBSD.org@localhost>
 >
 >    | >Synopsis:       sh(1): PID obtained with jobs -p is always 0 on
 > NetBSD 10.0 RC
 >
 >    | $ sh -c 'sleep 3 & echo $!; jobs -l; jobs -p'
 >    | 7975
 >    | [1] + 7975 Running            sleep 3 &
 >    | 0
 >
 >  This wasn't intended, and I am about to commit a fix, but at
 >  least according to POSIX, that isn't required to work.
 >
 >     -p Display only the process IDs for the process group leaders of
 > job-control
 >        background jobs and the process IDs associated with non-job-contro=
 l
 >        background jobs (if supported).
 >
 >  Non-interactive shells (which is what that is) don't enable job control,
 >  so that sleep 3 is a non-job-control background job, and we're not
 > required
 >  to support -p for those.
 >
 >  If job control were enabled, as in
 >
 >         sh -c 'set -m; sleep 3 & echo $!; jobs -l; jobs -p'
 >
 >  then it would work (in -10, and HEAD, without the coming fix).
 >
 >  The issue is a fix that was making sure the correct value was
 >  always output for job-control jobs (there were ways, in more complex
 >  examples, to get the wrong pid printed).   But the non-job-control
 >  ones just got forgotten.   Oops...
 >
 >  For now, in the non-job-control case, sh will just do what it used to do
 >  (while still doing it the new way for job-controlled background jobs).
 >
 >
 >
 
 --0000000000006d318e061031faed
 Content-Type: text/html; charset="UTF-8"
 Content-Transfer-Encoding: quoted-printable
 
 <div dir=3D"ltr"><div dir=3D"ltr"><div dir=3D"ltr">Thanks for the fixing an=
 d the detailed explanation.</div><div dir=3D"ltr">My concern was backward c=
 ompatibility.</div><div dir=3D"ltr">I probably won&#39;t use the jobs comma=
 nd with</div><div dir=3D"ltr">non-interactive shells (unless it is absolute=
 ly necessary).<br></div><br class=3D"gmail-Apple-interchange-newline"></div=
 ><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">2024=
 =E5=B9=B41=E6=9C=8831=E6=97=A5(=E6=B0=B4) 4:05 Robert Elz &lt;<a href=3D"ma=
 ilto:kre%munnari.oz.au@localhost">kre%munnari.oz.au@localhost</a>&gt;:<br></div><blockquote cla=
 ss=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid =
 rgb(204,204,204);padding-left:1ex">The following reply was made to PR bin/5=
 7894; it has been noted by GNATS.<br>
 <br>
 From: Robert Elz &lt;<a href=3D"mailto:kre%munnari.OZ.AU@localhost"; target=3D"_blank"=
 >kre%munnari.OZ.AU@localhost</a>&gt;<br>
 To: <a href=3D"mailto:gnats-bugs%netbsd.org@localhost"; target=3D"_blank">gnats-bugs@n=
 etbsd.org</a><br>
 Cc: <br>
 Subject: Re: bin/57894: sh(1): PID obtained with jobs -p is always 0 on Net=
 BSD 10.0 RC<br>
 Date: Wed, 31 Jan 2024 02:00:44 +0700<br>
 <br>
 =C2=A0 =C2=A0 =C2=A0Date:=C2=A0 =C2=A0 =C2=A0 =C2=A0 Tue, 30 Jan 2024 13:35=
 :00 +0000 (UTC)<br>
 =C2=A0 =C2=A0 =C2=A0From:=C2=A0 =C2=A0 =C2=A0 =C2=A0 <a href=3D"mailto:koic=
 hi%nksm.name@localhost" target=3D"_blank">koichi%nksm.name@localhost</a><br>
 =C2=A0 =C2=A0 =C2=A0Message-ID:=C2=A0 &lt;<a href=3D"mailto:20240130133500.=
 967921A923A%mollari.NetBSD.org@localhost" target=3D"_blank">20240130133500.967921A923=
 A%mollari.NetBSD.org@localhost</a>&gt;<br>
 <br>
 =C2=A0 =C2=A0| &gt;Synopsis:=C2=A0 =C2=A0 =C2=A0 =C2=A0sh(1): PID obtained =
 with jobs -p is always 0 on NetBSD 10.0 RC<br>
 <br>
 =C2=A0 =C2=A0| $ sh -c &#39;sleep 3 &amp; echo $!; jobs -l; jobs -p&#39;<br=
 >
 =C2=A0 =C2=A0| 7975<br>
 =C2=A0 =C2=A0| [1] + 7975 Running=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
 sleep 3 &amp;<br>
 =C2=A0 =C2=A0| 0<br>
 <br>
 =C2=A0This wasn&#39;t intended, and I am about to commit a fix, but at<br>
 =C2=A0least according to POSIX, that isn&#39;t required to work.<br>
 <br>
 =C2=A0 =C2=A0 -p Display only the process IDs for the process group leaders=
  of job-control<br>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0background jobs and the process IDs associated w=
 ith non-job-control<br>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0background jobs (if supported).<br>
 <br>
 =C2=A0Non-interactive shells (which is what that is) don&#39;t enable job c=
 ontrol,<br>
 =C2=A0so that sleep 3 is a non-job-control background job, and we&#39;re no=
 t required<br>
 =C2=A0to support -p for those.<br>
 <br>
 =C2=A0If job control were enabled, as in<br>
 <br>
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 sh -c &#39;set -m; sleep 3 &amp; echo $!; jobs =
 -l; jobs -p&#39;<br>
 <br>
 =C2=A0then it would work (in -10, and HEAD, without the coming fix).<br>
 <br>
 =C2=A0The issue is a fix that was making sure the correct value was<br>
 =C2=A0always output for job-control jobs (there were ways, in more complex<=
 br>
 =C2=A0examples, to get the wrong pid printed).=C2=A0 =C2=A0But the non-job-=
 control<br>
 =C2=A0ones just got forgotten.=C2=A0 =C2=A0Oops...<br>
 <br>
 =C2=A0For now, in the non-job-control case, sh will just do what it used to=
  do<br>
 =C2=A0(while still doing it the new way for job-controlled background jobs)=
 .<br>
 <br>
 <br>
 </blockquote></div></div>
 
 --0000000000006d318e061031faed--
 



Home | Main Index | Thread Index | Old Index