| delorie.com/archives/browse.cgi | search |
| DMARC-Filter: | OpenDMARC Filter v1.4.2 delorie.com 55UNlVNx3012363 |
| Authentication-Results: | delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com |
| Authentication-Results: | delorie.com; spf=pass smtp.mailfrom=cygwin.com |
| DKIM-Filter: | OpenDKIM Filter v2.11.0 delorie.com 55UNlVNx3012363 |
| Authentication-Results: | delorie.com; |
| dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=eTGrowiy | |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| DKIM-Filter: | OpenDKIM Filter v2.11.0 sourceware.org 99F4C385C40E |
| DKIM-Signature: | v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; |
| s=default; t=1751327249; | |
| bh=ZuByqN998uz0WQnEk0pczoUhah0am5c9LV2I/3B3j0A=; | |
| h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: | |
| List-Help:List-Subscribe:From:Reply-To:From; | |
| b=eTGrowiyZAXZGSul64qvN66ncWid+gN73UMbpnd6gCAEfYSarEJdCifezKpZNa35j | |
| +O1AjBYbIqt/IgdWGhpbycksMerPfifc8r6GwT5CoqucnKh5T7/rgVYDVXPilnGTdH | |
| F9zI6Z8uV9fed2eqAt7P9JfuM2TRDU5ZE2bXpI58= | |
| X-Original-To: | cygwin AT cygwin DOT com |
| Delivered-To: | cygwin AT cygwin DOT com |
| DMARC-Filter: | OpenDMARC Filter v1.4.2 sourceware.org DB0B93858431 |
| ARC-Filter: | OpenARC Filter v1.0.0 sourceware.org DB0B93858431 |
| ARC-Seal: | i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1751327224; cv=none; |
| b=xyyljQsEE0nAGlzrjXeBss7ewsz4O+NaLbmTBq7Rp5rglNmqlgO4kIvHrfeD9FImEZdeLPY1jUdwz6TMbjm3D1eJO1QIPN0dD1C+hQ5t6V3zLBaab+VQsGnKRxgZ9t/L0SXUdMlmu7JPmJsbWJBjUsZNOzK6zL24Qj2ZQwoNY3Y= | |
| ARC-Message-Signature: | i=1; a=rsa-sha256; d=sourceware.org; s=key; |
| t=1751327224; c=relaxed/simple; | |
| bh=khqyJjptmdBTUjud9nwgYdMMaDgeMVbnXWmjxMrY/Zg=; | |
| h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; | |
| b=J33IZcjnQHo2TTfsTxKQJVxFoGG0Jo/krRPfNSFLob2Ta9/8xBvgFhFWTMjQ3cdEqIbL6z5SZk+fgkyjrOTaaHGm2vqWHXU29a3TS6cMz2bTcZZANFj0Q8tutQesfAV11M8TO1h91M5mIhVaO1NwgJ5JjMWCrE/xDpYBsI5EbAQ= | |
| ARC-Authentication-Results: | i=1; server2.sourceware.org |
| DKIM-Filter: | OpenDKIM Filter v2.11.0 sourceware.org DB0B93858431 |
| Date: | Mon, 30 Jun 2025 16:47:03 -0700 (PDT) |
| X-X-Sender: | jeremyd AT resin DOT csoft DOT net |
| To: | cygwin AT cygwin DOT com |
| Subject: | possible race initializing pgid in spawned child |
| Message-ID: | <be85113b-4082-4beb-27c7-66a7171e818c@jdrake.com> |
| MIME-Version: | 1.0 |
| X-BeenThere: | cygwin AT cygwin DOT com |
| X-Mailman-Version: | 2.1.30 |
| List-Id: | General Cygwin discussions and problem reports <cygwin.cygwin.com> |
| List-Archive: | <https://cygwin.com/pipermail/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-request AT cygwin DOT com?subject=help> |
| List-Subscribe: | <https://cygwin.com/mailman/listinfo/cygwin>, |
| <mailto:cygwin-request AT cygwin DOT com?subject=subscribe> | |
| From: | Jeremy Drake via Cygwin <cygwin AT cygwin DOT com> |
| Reply-To: | Jeremy Drake <cygwin AT jdrake DOT com> |
| Sender: | "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com> |
I cannot duplicate this failure locally, but in GHA the following test
case fails with
Process group 0 != expected 704
child exited with code 1
FAIL winsup.api/spawnpgid.exe (exit status: 1)
I suspect there must be a race between the child process calling getpgid
and the parent running "vchild->pgid = myself->pgid" in sigproc.cc
proc_subproc PROC_ADD_CHILD.
---
winsup/testsuite/Makefile.am | 1 +
winsup/testsuite/winsup.api/spawnpgid.c | 59 +++++++++++++++++++++++++
2 files changed, 60 insertions(+)
create mode 100644 winsup/testsuite/winsup.api/spawnpgid.c
diff --git a/winsup/testsuite/Makefile.am b/winsup/testsuite/Makefile.am
index 67898f62a6..8f101695d5 100644
--- a/winsup/testsuite/Makefile.am
+++ b/winsup/testsuite/Makefile.am
@@ -48,6 +48,7 @@ check_PROGRAMS = \
winsup.api/shmtest \
winsup.api/sigchld \
winsup.api/signal-into-win32-api \
+ winsup.api/spawnpgid \
winsup.api/systemcall \
winsup.api/user_malloc \
winsup.api/waitpid \
diff --git a/winsup/testsuite/winsup.api/spawnpgid.c b/winsup/testsuite/winsup.api/spawnpgid.c
new file mode 100644
index 0000000000..214af9306d
--- /dev/null
+++ b/winsup/testsuite/winsup.api/spawnpgid.c
@@ -0,0 +1,59 @@
+#include <process.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+int handle_child (char *arg)
+{
+ pid_t pgid = getpgid (0);
+ pid_t expectedpgid = atoi (arg);
+ if (!expectedpgid)
+ expectedpgid = getpid ();
+ if (pgid != expectedpgid)
+ {
+ fprintf (stderr, "Process group %d != expected %d\n", pgid, expectedpgid);
+ return 1;
+ }
+ return 0;
+}
+
+int main (int argc, char **argv)
+{
+ int status;
+ char buf[12];
+ const char * const childargv[] = {"pgroup", "--child", buf, NULL};
+
+ /* unbuffer stdout */
+ setvbuf(stdout, NULL, _IONBF, 0);
+
+ if (argc == 3 && !strcmp (argv[1], "--child"))
+ return handle_child (argv[2]);
+
+ /* ensure pgroup inherited by default */
+ sprintf (buf, "%d", getpgid (0));
+ status = spawnv (_P_WAIT, "/proc/self/exe", childargv);
+ if (status < 0)
+ {
+ perror ("spawnv");
+ return 1;
+ }
+ else if (WIFSIGNALED (status))
+ {
+ fprintf (stderr, "child termintated with signal %d\n", WTERMSIG (status));
+ return 1;
+ }
+ else if (WIFEXITED (status) && WEXITSTATUS (status) != 0)
+ {
+ fprintf (stderr, "child exited with code %d\n", WEXITSTATUS (status));
+ return 1;
+ }
+ else if (!WIFEXITED (status))
+ {
+ fprintf (stderr, "child terminated with status %x\n", status);
+ return 1;
+ }
+
+ return 0;
+}
--
2.49.0.windows.1
--
Problem reports: https://cygwin.com/problems.html
FAQ: https://cygwin.com/faq/
Documentation: https://cygwin.com/docs.html
Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |