Mail Archives: cygwin/2019/02/08/08:32:17
X-Recipient: | archive-cygwin AT delorie DOT com
|
DomainKey-Signature: | a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
|
| :list-unsubscribe:list-subscribe:list-archive:list-post
|
| :list-help:sender:date:from:to:cc:subject:message-id:reply-to
|
| :references:mime-version:content-type:in-reply-to; q=dns; s=
|
| default; b=DNGHGmnLCZKgpeQwNhtyzpKIWO/3QZUEz9PbsMx1CiMSJWBtE7nMh
|
| IpY1Beup0Zb/tuZDeP/C13KCVCBTegAgFyItTL5pZIPE5vsHZ+z+FVNJqS3+BqtS
|
| Ih8dZ/Ngs9OxkLaEkxoVNVdNezjTa44m6f/q12g0VfvzcIYxBdUUUA=
|
DKIM-Signature: | v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
|
| :list-unsubscribe:list-subscribe:list-archive:list-post
|
| :list-help:sender:date:from:to:cc:subject:message-id:reply-to
|
| :references:mime-version:content-type:in-reply-to; s=default;
|
| bh=YjaZeVNmxjos+VpmdIEB/7AaZi0=; b=uU9eiQaGPHlK5yVP5hhzupflwUCW
|
| Lq5h5WlOaqSw84iiIxed18hNW5Ht8sT5QdGz2IWREG0mz5RWc0xbjB0iL+1Gr+CE
|
| +7cNJIviQu8kor2I9IJhzGej+st+yjINl/qp0+/TgVlb3NMHpxIF4tN9w3agcXWM
|
| vheRo8qbYakdIe8=
|
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm
|
List-Id: | <cygwin.cygwin.com>
|
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com>
|
List-Archive: | <http://sourceware.org/ml/cygwin/>
|
List-Post: | <mailto:cygwin AT cygwin DOT com>
|
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
|
Sender: | cygwin-owner AT cygwin DOT com
|
Mail-Followup-To: | cygwin AT cygwin DOT com
|
Delivered-To: | mailing list cygwin AT cygwin DOT com
|
Authentication-Results: | sourceware.org; auth=none
|
X-Spam-SWARE-Status: | No, score=-125.4 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,GOOD_FROM_CORINNA_CYGWIN,KAM_LAZY_DOMAIN_SECURITY,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=
|
X-HELO: | mout.kundenserver.de
|
Date: | Fri, 8 Feb 2019 14:28:07 +0100
|
From: | Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
|
To: | Michael Haubenwallner <michael DOT haubenwallner AT ssi-schaefer DOT com>
|
Cc: | cygwin AT cygwin DOT com
|
Subject: | Re: [ANNOUNCEMENT] TEST: Cygwin 3.0.0-0.7
|
Message-ID: | <20190208132807.GP13951@calimero.vinschen.de>
|
Reply-To: | cygwin AT cygwin DOT com
|
Mail-Followup-To: | Michael Haubenwallner <michael DOT haubenwallner AT ssi-schaefer DOT com>, cygwin AT cygwin DOT com
|
References: | <announce DOT 20190205151855 DOT GD16130 AT calimero DOT vinschen DOT de> <02da4eeb-fcce-b1bc-e6eb-68ff3ec0cf74 AT ssi-schaefer DOT com> <20190207182735 DOT GG13951 AT calimero DOT vinschen DOT de> <8a2f041f-f8f7-6e17-5d97-5a168440009b AT ssi-schaefer DOT com> <20190208113158 DOT GH13951 AT calimero DOT vinschen DOT de> <17e339bb-2115-bf22-7291-04215aab3150 AT ssi-schaefer DOT com> <20190208122126 DOT GM13951 AT calimero DOT vinschen DOT de> <20190208122338 DOT GN13951 AT calimero DOT vinschen DOT de> <b07e6ba2-0ce0-4662-7a02-bda6ce3b0108 AT ssi-schaefer DOT com> <20190208130635 DOT GO13951 AT calimero DOT vinschen DOT de>
|
MIME-Version: | 1.0
|
In-Reply-To: | <20190208130635.GO13951@calimero.vinschen.de>
|
User-Agent: | Mutt/1.10.1 (2018-07-13)
|
--aqWxf8ydqYKP8htK
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Feb 8 14:06, Corinna Vinschen wrote:
> On Feb 8 13:52, Michael Haubenwallner wrote:
> > On 2/8/19 1:23 PM, Corinna Vinschen wrote:
> > > On Feb 8 13:21, Corinna Vinschen wrote:
> > >> On Feb 8 12:51, Michael Haubenwallner wrote:
> > >>>
> > >>> For now it seems like there's an inconsistency with PIDs:
> > >>> A first process PID 100, receives PID 101 from spawn(),
> > >>> but in the new process getpid() returns 102:
> > >>>
> > >>> $ ./dospawn /bin/bash -c 'echo $$'
> > >>> 12625
> > >>> waitpid: pid 12624 status 0x0
> > >>
> > >> Oh, hmm. If you call spawnve, rather than execve, a new child pid
> > >> is generated in spawnve, rather than just keeping the callers pid.
> > >>
> > >> However, apparently the child invents its own pid in pinfo::thisproc
> > >> after being spawned. But actually this should only occur for forked
> > >> processes aore processes started from non-Cygwin parents.
> > >=20
> > > Does that help, by any chance:
> > > [nope]
> >=20
> > How should the child be informed at all about the new cygpid value gene=
rated in
> > parent's child_info_spawn::worker() ?
>=20
> I just realized this myself. The old method creating Cygwin pids just
> fetched the pid from GetCurrentProcessId(), which was right for spawned
> (but not execed) processes. For the new pid we might have to give this
> to the child via child_info_spawn.
This works for me, can you test this, too, please?
diff --git a/winsup/cygwin/child_info.h b/winsup/cygwin/child_info.h
index 67264119eae9..847614ff299a 100644
--- a/winsup/cygwin/child_info.h
+++ b/winsup/cygwin/child_info.h
@@ -144,6 +144,7 @@ class child_info_spawn: public child_info
{
HANDLE hExeced;
HANDLE ev;
+ pid_t cygpid;
public:
cygheap_exec_info *moreinfo;
int __stdin;
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 78506d43de29..11edcdf0d21b 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -652,11 +652,16 @@ child_info_spawn::handle_spawn ()
cygheap_fixup_in_child (true);
memory_init ();
}
+
+ cygheap->pid =3D cygpid;
+
+ /* Spawned process sets h to INVALID_HANDLE_VALUE to notify
+ pinfo::thisproc not to create another pid. */
if (!moreinfo->myself_pinfo ||
!DuplicateHandle (GetCurrentProcess (), moreinfo->myself_pinfo,
GetCurrentProcess (), &h, 0,
FALSE, DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE))
- h =3D NULL;
+ h =3D (type =3D=3D _CH_SPAWN) ? INVALID_HANDLE_VALUE : NULL;
=20
/* Setup our write end of the process pipe. Clear the one in the struct=
ure.
The destructor should never be called for this but, it can't hurt to =
be
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
index 445bd35b224e..61fbc9bc19bf 100644
--- a/winsup/cygwin/pinfo.cc
+++ b/winsup/cygwin/pinfo.cc
@@ -57,11 +57,15 @@ pinfo::thisproc (HANDLE h)
procinfo =3D NULL;
=20
DWORD flags =3D PID_IN_USE | PID_ACTIVE;
+ /* Forked process or process started from non-Cygwin parent needs a pid.=
*/
if (!h)
{
cygheap->pid =3D create_cygwin_pid ();
flags |=3D PID_NEW;
}
+ /* spawnve'd process got pid from parent. */
+ else if (h =3D=3D INVALID_HANDLE_VALUE)
+ h =3D NULL;
=20
init (cygheap->pid, flags, h);
procinfo->process_state |=3D PID_IN_USE;
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index d969c66ea19a..ebc34d10542f 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -258,7 +258,6 @@ child_info_spawn::worker (const char *prog_arg, const c=
har *const *argv,
int in__stdin, int in__stdout)
{
bool rc;
- pid_t cygpid;
int res =3D -1;
=20
/* Check if we have been called from exec{lv}p or spawn{lv}p and mask
@@ -578,6 +577,8 @@ child_info_spawn::worker (const char *prog_arg, const c=
har *const *argv,
if (!real_path.iscygexec () && mode =3D=3D _P_OVERLAY)
myself->process_state |=3D PID_NOTCYGWIN;
=20
+ cygpid =3D (mode !=3D _P_OVERLAY) ? create_cygwin_pid () : myself->p=
id;
+
wchar_t wcmd[(size_t) cmd];
if (!::cygheap->user.issetuid ()
|| (::cygheap->user.saved_uid =3D=3D ::cygheap->user.real_uid
@@ -708,11 +709,6 @@ child_info_spawn::worker (const char *prog_arg, const =
char *const *argv,
if (::cygheap->fdtab.need_fixup_before ())
::cygheap->fdtab.fixup_before_exec (pi.dwProcessId);
=20
- if (mode !=3D _P_OVERLAY)
- cygpid =3D create_cygwin_pid ();
- else
- cygpid =3D myself->pid;
-
/* Print the original program name here so the user can see that too=
. */
syscall_printf ("pid %d, prog_arg %s, cmd line %.9500s)",
rc ? cygpid : (unsigned int) -1, prog_arg, (const char *) cmd);
I pushed your forkable branch to master, btw. Would you mind to do the
honors in the ;rease notes at cygwin/release/3.0 and doc/new-features.xml?
Thanks,
Corinna
--=20
Corinna Vinschen
Cygwin Maintainer
--aqWxf8ydqYKP8htK
Content-Type: application/pgp-signature; name="signature.asc"
-----BEGIN PGP SIGNATURE-----
iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAlxdg+cACgkQ9TYGna5E
T6DgFQ//Wfov5VjGdSxX9ZlI85e561iTvqwTDGgglDWW7TyyPAnd58Iz/PSwpmNf
rua7GrlTWnludeygu+TPcz/GoxqFOp5UfI4O+pGWFnr/gzT4dLnG9uptjWd6ARXE
st0pPYQcWnKNis3dsDNr6TnmxrGAJy8f7O0XWcbf4Tyw9YNSLUcP+274+2hr5eIJ
hHZtCMv9lQKTxwEWzMY371ISTiDnENKyO25wS1ddrQcoqW3N9dtXgIm6KOR1Wm5d
pfMuZbXwh/uHE/Yyq+uPoGT9T0KPdd69GMLzsofC38HA6rR+L4X/zu4PkaKdSVhK
sEX/ClXUS5Muckcb/Wap8ETi7Hz01ytvG36kf0lSO+iI3MGxT6ChKbSnEYJVZqmj
B9loLipjEAEyBcRVi2dnMCly1EwKxKu3nXd8h0i0379CJs5wBVVK3d+tbdJn7NfT
VZSQWA90sKXppte3AYkys3GlKvl6WDSaLCZhAhhr6ekT/DBIOwGgTuTeidRy/jI/
topea9UHcY7Rs5KMvnKJEtGHHY1ulJRhhl4s4XSf/vy1M5hahYzaSIFNapDLZqb7
CTZIKM6c6ozb5TKQA9IOtAlgrX62slkFxXHOiHb51KZhCl1rOErG5jDuzg2upmSs
e7RL2qZiWKjL+gyl/+XLREL3I0V6YooXPxaa2QTZ/DZdbNRIfyM=
=9/fb
-----END PGP SIGNATURE-----
--aqWxf8ydqYKP8htK--
- Raw text -