unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 1/3] support: Add support_process_state_wait
@ 2020-02-18 14:02 Adhemerval Zanella
  2020-02-18 14:02 ` [PATCH v2 2/3] posix: Refactor tst-waitid (BZ #14666) Adhemerval Zanella
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Adhemerval Zanella @ 2020-02-18 14:02 UTC (permalink / raw)
  To: libc-alpha

Changes from previous version:

  - Handle process name with spaces.
  - Fallback to nanosleep for invalid states.
  - Set process_states_t as const object.

--

It allows parent process to wait for children state using a polling
strategy over procfs on Linux.  The polling is used over ptrace to
avoid the need to handle signals on the target pid and to handle some
system specific limitation (such as YAMA).

The polling has some limitations, such as resource consumption due
the procfs read in a loop and the lack of synchronization after the
state is obtained.

The interface idea is to simplify some sleep synchronization waitid
tests and is to reduce timeouts by replacing arbitrary waits.
---
 support/Makefile                    |   3 +
 support/process_state.h             |  47 +++++++++++++
 support/support_process_state.c     |  92 ++++++++++++++++++++++++
 support/tst-support-process_state.c | 105 ++++++++++++++++++++++++++++
 support/xgetline.c                  |  34 +++++++++
 support/xstdio.h                    |   2 +
 6 files changed, 283 insertions(+)
 create mode 100644 support/process_state.h
 create mode 100644 support/support_process_state.c
 create mode 100644 support/tst-support-process_state.c
 create mode 100644 support/xgetline.c

diff --git a/support/Makefile b/support/Makefile
index a0304e6def..6e38b87ebe 100644
--- a/support/Makefile
+++ b/support/Makefile
@@ -56,6 +56,7 @@ libsupport-routines = \
   support_format_hostent \
   support_format_netent \
   support_isolate_in_subprocess \
+  support_process_state \
   support_ptrace \
   support_openpty \
   support_paths \
@@ -95,6 +96,7 @@ libsupport-routines = \
   xfopen \
   xfork \
   xftruncate \
+  xgetline \
   xgetsockname \
   xlisten \
   xlseek \
@@ -224,6 +226,7 @@ tests = \
   tst-support_capture_subprocess \
   tst-support_descriptors \
   tst-support_format_dns_packet \
+  tst-support-process_state \
   tst-support_quote_blob \
   tst-support_quote_string \
   tst-support_record_failure \
diff --git a/support/process_state.h b/support/process_state.h
new file mode 100644
index 0000000000..90c4a1eea4
--- /dev/null
+++ b/support/process_state.h
@@ -0,0 +1,47 @@
+/* Wait for process state.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef SUPPORT_PROCESS_STATE_H
+#define SUPPORT_PROCESS_STATE_H
+
+#include <sys/types.h>
+
+enum support_process_state
+{
+  support_process_state_running      = 0x01,  /* R (running).  */
+  support_process_state_sleeping     = 0x02,  /* S (sleeping).  */
+  support_process_state_disk_sleep   = 0x04,  /* D (disk sleep).  */
+  support_process_state_stopped      = 0x08,  /* T (stopped).  */
+  support_process_state_tracing_stop = 0x10,  /* t (tracing stop).  */
+  support_process_state_dead         = 0x20,  /* X (dead).  */
+  support_process_state_zombie       = 0x40,  /* Z (zombie).  */
+  support_process_state_parked       = 0x80,  /* P (parked).  */
+};
+
+/* Wait for process PID to reach state STATE.  It can be a combination of
+   multiple possible states ('process_state_running | process_state_sleeping')
+   where the function return when any of these state are observed.
+   The timeout POLL_TS might be used to wait before polling the PID status
+   information from the kernel.  A NULL value will set to use a default
+   value (10000000 ns).
+   For an invalid state not represented by SUPPORT_PROCESS_STATE, it fallbacks
+   to a 2 second sleep.  */
+void support_process_state_wait (pid_t pid, enum support_process_state state,
+				 struct timespec *poll_ts);
+
+#endif
diff --git a/support/support_process_state.c b/support/support_process_state.c
new file mode 100644
index 0000000000..29ba79a5d2
--- /dev/null
+++ b/support/support_process_state.c
@@ -0,0 +1,92 @@
+/* Wait for process state.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <stdlib.h>
+#include <time.h>
+#include <string.h>
+
+#include <array_length.h>
+
+#include <support/process_state.h>
+#include <support/xstdio.h>
+#include <support/check.h>
+
+void
+support_process_state_wait (pid_t pid, enum support_process_state state,
+			    struct timespec *poll_ts)
+{
+#ifdef __linux__
+  /* For Linux it does a polling check on /proc/<pid>/status checking on
+     third field.  */
+
+  /* It mimics the kernel states from fs/proc/array.c  */
+  static const struct process_states
+  {
+    enum support_process_state s;
+    char v;
+  } process_states[] = {
+    { support_process_state_running,      'R' },
+    { support_process_state_sleeping,     'S' },
+    { support_process_state_disk_sleep,   'D' },
+    { support_process_state_stopped,      'T' },
+    { support_process_state_tracing_stop, 't' },
+    { support_process_state_dead,         'X' },
+    { support_process_state_zombie,       'Z' },
+    { support_process_state_parked,       'P' },
+  };
+
+  char spath[sizeof ("/proc/" + 3) * sizeof (pid_t) + sizeof ("/status") + 1];
+  snprintf (spath, sizeof (spath), "/proc/%i/status", pid);
+
+  FILE *fstatus = xfopen (spath, "r");
+  char *line = NULL;
+  size_t linesiz = 0;
+
+  for (;;)
+    {
+      char cur_state = -1;
+      while (xgetline (&line, &linesiz, fstatus) != -1)
+	if (strncmp (line, "State:", strlen ("State:")) == 0)
+	  {
+	    TEST_COMPARE (sscanf (line, "%*s %c", &cur_state), 1);
+	    break;
+	  }
+      /* Fallback to nanosleep for invalid state.  */
+      if (cur_state == -1)
+	break;
+
+      for (size_t i = 0; i < array_length (process_states); ++i)
+	if (state & process_states[i].s && cur_state == process_states[i].v)
+	  {
+	    free (line);
+	    xfclose (fstatus);
+	    return;
+	  }
+
+      rewind (fstatus);
+      fflush (fstatus);
+
+      nanosleep (poll_ts ? poll_ts : &(struct timespec) { 0, 10000000 }, NULL);
+    }
+
+  free (line);
+  xfclose (fstatus);
+  /* Fallback to nanosleep if an invalid state is found.  */
+#endif
+  nanosleep (&(struct timespec) { 2, 0 }, NULL);
+}
diff --git a/support/tst-support-process_state.c b/support/tst-support-process_state.c
new file mode 100644
index 0000000000..4f85f571fb
--- /dev/null
+++ b/support/tst-support-process_state.c
@@ -0,0 +1,105 @@
+/* Wait for process state tests.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <stdio.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include <support/test-driver.h>
+#include <support/process_state.h>
+#include <support/check.h>
+#include <support/xsignal.h>
+#include <support/xunistd.h>
+
+#ifndef WEXITED
+# define WEXITED	0
+#endif
+
+static void
+sigusr1_handler (int signo)
+{
+}
+
+static void
+test_child (void)
+{
+  xsignal (SIGUSR1, sigusr1_handler);
+
+  raise (SIGSTOP);
+
+  TEST_COMPARE (pause (), -1);
+  TEST_COMPARE (errno, EINTR);
+
+  while (1)
+    asm ("");
+}
+
+static int
+do_test (void)
+{
+  pid_t pid = xfork ();
+  if (pid == 0)
+    {
+      test_child ();
+      _exit (127);
+    }
+
+  /* Adding process_state_tracing_stop ('t') allows the test to work under
+     trace programs such as ptrace.  */
+  enum support_process_state stop_state = support_process_state_stopped
+				    | support_process_state_tracing_stop;
+
+  if (test_verbose)
+    printf ("info: waiting pid %d, state_stopped/state_tracing_stop\n",
+	    (int) pid);
+  support_process_state_wait (pid, stop_state, NULL);
+
+  if (kill (pid, SIGCONT) != 0)
+    FAIL_RET ("kill (%d, SIGCONT): %m\n", pid);
+
+  if (test_verbose)
+    printf ("info: waiting pid %d, state_sleeping\n", (int) pid);
+  support_process_state_wait (pid, support_process_state_sleeping, NULL);
+
+  if (kill (pid, SIGUSR1) != 0)
+    FAIL_RET ("kill (%d, SIGUSR1): %m\n", pid);
+
+  if (test_verbose)
+    printf ("info: waiting pid %d, state_running\n", (int) pid);
+  support_process_state_wait (pid, support_process_state_running, NULL);
+
+  if (kill (pid, SIGKILL) != 0)
+    FAIL_RET ("kill (%d, SIGKILL): %m\n", pid);
+
+  if (test_verbose)
+    printf ("info: waiting pid %d, state_zombie\n", (int) pid);
+  support_process_state_wait (pid, support_process_state_zombie, NULL);
+
+  siginfo_t info;
+  int r = waitid (P_PID, pid, &info, WEXITED);
+  TEST_COMPARE (r, 0);
+  TEST_COMPARE (info.si_signo, SIGCHLD);
+  TEST_COMPARE (info.si_code, CLD_KILLED);
+  TEST_COMPARE (info.si_status, SIGKILL);
+  TEST_COMPARE (info.si_pid, pid);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/support/xgetline.c b/support/xgetline.c
new file mode 100644
index 0000000000..5b010bcf56
--- /dev/null
+++ b/support/xgetline.c
@@ -0,0 +1,34 @@
+/* fopen with error checking.
+   Copyright (C) 2016-2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <support/xstdio.h>
+
+#include <support/check.h>
+#include <errno.h>
+
+ssize_t
+xgetline (char **lineptr, size_t *n, FILE *stream)
+{
+  int old_errno = errno;
+  errno = 0;
+  ssize_t ret = getline (lineptr, n, stream);
+  if (ret == -1 && errno != 0)
+    FAIL_EXIT1 ("getline failed: %m");
+  errno = old_errno;
+  return ret;
+}
diff --git a/support/xstdio.h b/support/xstdio.h
index b62267a2a2..143957b6a8 100644
--- a/support/xstdio.h
+++ b/support/xstdio.h
@@ -27,6 +27,8 @@ __BEGIN_DECLS
 FILE *xfopen (const char *path, const char *mode);
 void xfclose (FILE *);
 
+ssize_t xgetline (char **lineptr, size_t *n, FILE *stream);
+
 __END_DECLS
 
 #endif /* SUPPORT_XSTDIO_H */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 2/3] posix: Refactor tst-waitid (BZ #14666)
  2020-02-18 14:02 [PATCH v2 1/3] support: Add support_process_state_wait Adhemerval Zanella
@ 2020-02-18 14:02 ` Adhemerval Zanella
  2020-02-18 17:47   ` Adhemerval Zanella
  2020-02-18 14:02 ` [PATCH v2 3/3] posix: Remove posix waitid Adhemerval Zanella
  2020-02-18 15:17 ` [PATCH v2 1/3] support: Add support_process_state_wait Florian Weimer
  2 siblings, 1 reply; 12+ messages in thread
From: Adhemerval Zanella @ 2020-02-18 14:02 UTC (permalink / raw)
  To: libc-alpha

Changes from previous version:

  - Use sigwaitinfo instead of global variables set by the signal handler.

--

The main changes are:

  - Adapt to libsupport.
  - Synchronize the signal handler using atomics.
  - Replace waitpid by waitid calls.
  - Use support_process_state_wait to wait for child state.
  - Add tests for P_PGID and P_ALL.
  - Use sigwaitinfo instead of global state set by the signal handler.

Checked on x86_64-linux-gnu and i686-linux-gnu.
---
 posix/tst-waitid.c | 561 ++++++++++++++-------------------------------
 1 file changed, 166 insertions(+), 395 deletions(-)

diff --git a/posix/tst-waitid.c b/posix/tst-waitid.c
index c4725489ea..2331c42e66 100644
--- a/posix/tst-waitid.c
+++ b/posix/tst-waitid.c
@@ -22,13 +22,20 @@
 #include <unistd.h>
 #include <sys/wait.h>
 #include <signal.h>
+#include <time.h>
+#include <stdatomic.h>
+#include <stdbool.h>
+
+#include <support/xsignal.h>
+#include <support/xunistd.h>
+#include <support/check.h>
+#include <support/process_state.h>
 
 static void
-test_child (void)
+test_child (bool setgroup)
 {
-  /* Wait a second to be sure the parent set his variables before we
-     produce a SIGCHLD.  */
-  sleep (1);
+  if (setgroup)
+    TEST_COMPARE (setpgid (0, 0), 0);
 
   /* First thing, we stop ourselves.  */
   raise (SIGSTOP);
@@ -44,475 +51,239 @@ test_child (void)
 # define WSTOPPED	WUNTRACED
 #endif
 
-static sig_atomic_t expecting_sigchld, spurious_sigchld;
-#ifdef SA_SIGINFO
-static siginfo_t sigchld_info;
+/* Set with only SIGCHLD on do_test_waitid.  */
+static sigset_t chldset;
 
+#ifdef SA_SIGINFO
 static void
 sigchld (int signo, siginfo_t *info, void *ctx)
 {
-  if (signo != SIGCHLD)
-    {
-      printf ("SIGCHLD handler got signal %d instead!\n", signo);
-      _exit (EXIT_FAILURE);
-    }
-
-  if (! expecting_sigchld)
-    {
-      spurious_sigchld = 1;
-      printf ("spurious SIGCHLD: signo %d code %d status %d pid %d\n",
-	      info->si_signo, info->si_code, info->si_status, info->si_pid);
-    }
-  else
-    {
-      sigchld_info = *info;
-      expecting_sigchld = 0;
-    }
 }
+#endif
 
 static void
-check_sigchld (const char *phase, int *ok, int code, int status, pid_t pid)
+check_sigchld (int code, int status, pid_t pid)
 {
-  if (expecting_sigchld)
-    {
-      printf ("missing SIGCHLD on %s\n", phase);
-      *ok = EXIT_FAILURE;
-      expecting_sigchld = 0;
-      return;
-    }
+#ifdef SA_SIGINFO
+  siginfo_t siginfo;
+  TEST_COMPARE (sigwaitinfo (&chldset, &siginfo), SIGCHLD);
 
-  if (sigchld_info.si_signo != SIGCHLD)
-    {
-      printf ("SIGCHLD for %s signal %d\n", phase, sigchld_info.si_signo);
-      *ok = EXIT_FAILURE;
-    }
-  if (sigchld_info.si_code != code)
-    {
-      printf ("SIGCHLD for %s code %d\n", phase, sigchld_info.si_code);
-      *ok = EXIT_FAILURE;
-    }
-  if (sigchld_info.si_status != status)
-    {
-      printf ("SIGCHLD for %s status %d\n", phase, sigchld_info.si_status);
-      *ok = EXIT_FAILURE;
-    }
-  if (sigchld_info.si_pid != pid)
-    {
-      printf ("SIGCHLD for %s pid %d\n", phase, sigchld_info.si_pid);
-      *ok = EXIT_FAILURE;
-    }
-}
-# define CHECK_SIGCHLD(phase, code_check, status_check) \
-  check_sigchld ((phase), &status, (code_check), (status_check), pid)
-#else
-# define CHECK_SIGCHLD(phase, code, status) ((void) 0)
+  TEST_COMPARE (siginfo.si_signo, SIGCHLD);
+  TEST_COMPARE (siginfo.si_code, code);
+  TEST_COMPARE (siginfo.si_status, status);
+  TEST_COMPARE (siginfo.si_pid, pid);
 #endif
+}
 
 static int
-do_test (int argc, char *argv[])
+do_test_waitd_common (idtype_t type, pid_t pid)
 {
-#ifdef SA_SIGINFO
-  struct sigaction sa;
-  sa.sa_flags = SA_SIGINFO|SA_RESTART;
-  sa.sa_sigaction = &sigchld;
-  if (sigemptyset (&sa.sa_mask) < 0 || sigaction (SIGCHLD, &sa, NULL) < 0)
-    {
-      printf ("setting SIGCHLD handler: %m\n");
-      return EXIT_FAILURE;
-    }
-#endif
+  /* Adding process_state_tracing_stop ('t') allows the test to work under
+     trace programs such as ptrace.  */
+  enum process_state_t stop_state = process_state_stopped
+				    | process_state_tracing_stop;
 
-  expecting_sigchld = 1;
+  support_process_state_wait (pid, stop_state);
 
-  pid_t pid = fork ();
-  if (pid < 0)
-    {
-      printf ("fork: %m\n");
-      return EXIT_FAILURE;
-    }
-  else if (pid == 0)
-    {
-      test_child ();
-      _exit (127);
-    }
-
-  int status = EXIT_SUCCESS;
-#define RETURN(ok) \
-    do { if (status == EXIT_SUCCESS) status = (ok); goto out; } while (0)
-
-  /* Give the child a chance to stop.  */
-  sleep (3);
-
-  CHECK_SIGCHLD ("stopped (before waitid)", CLD_STOPPED, SIGSTOP);
+  check_sigchld (CLD_STOPPED, SIGSTOP, pid);
 
   /* Now try a wait that should not succeed.  */
   siginfo_t info;
+  int fail;
+
   info.si_signo = 0;		/* A successful call sets it to SIGCHLD.  */
-  int fail = waitid (P_PID, pid, &info, WEXITED|WCONTINUED|WNOHANG);
-  switch (fail)
-    {
-    default:
-      printf ("waitid returned bogus value %d\n", fail);
-      RETURN (EXIT_FAILURE);
-    case -1:
-      printf ("waitid WNOHANG on stopped: %m\n");
-      RETURN (errno == ENOTSUP ? EXIT_SUCCESS : EXIT_FAILURE);
-    case 0:
-      if (info.si_signo == 0)
-	break;
-      if (info.si_signo == SIGCHLD)
-	printf ("waitid WNOHANG on stopped status %d\n", info.si_status);
-      else
-	printf ("waitid WNOHANG on stopped signal %d\n", info.si_signo);
-      RETURN (EXIT_FAILURE);
-    }
+  fail = waitid (P_PID, pid, &info, WEXITED|WCONTINUED|WNOHANG);
+  if (fail == -1 && errno == ENOTSUP)
+    FAIL_RET ("waitid WNOHANG on stopped: %m");
+  TEST_COMPARE (fail, 0);
+  TEST_COMPARE (info.si_signo, 0);
 
   /* Next the wait that should succeed right away.  */
   info.si_signo = 0;		/* A successful call sets it to SIGCHLD.  */
   info.si_pid = -1;
   info.si_status = -1;
   fail = waitid (P_PID, pid, &info, WSTOPPED|WNOHANG);
-  switch (fail)
-    {
-    default:
-      printf ("waitid WSTOPPED|WNOHANG returned bogus value %d\n", fail);
-      RETURN (EXIT_FAILURE);
-    case -1:
-      printf ("waitid WSTOPPED|WNOHANG on stopped: %m\n");
-      RETURN (errno == ENOTSUP ? EXIT_SUCCESS : EXIT_FAILURE);
-    case 0:
-      if (info.si_signo != SIGCHLD)
-	{
-	  printf ("waitid WSTOPPED|WNOHANG on stopped signal %d\n",
-		  info.si_signo);
-	  RETURN (EXIT_FAILURE);
-	}
-      if (info.si_code != CLD_STOPPED)
-	{
-	  printf ("waitid WSTOPPED|WNOHANG on stopped code %d\n",
-		  info.si_code);
-	  RETURN (EXIT_FAILURE);
-	}
-      if (info.si_status != SIGSTOP)
-	{
-	  printf ("waitid WSTOPPED|WNOHANG on stopped status %d\n",
-		  info.si_status);
-	  RETURN (EXIT_FAILURE);
-	}
-      if (info.si_pid != pid)
-	{
-	  printf ("waitid WSTOPPED|WNOHANG on stopped pid %d != %d\n",
-		  info.si_pid, pid);
-	  RETURN (EXIT_FAILURE);
-	}
-    }
+  if (fail == -1 && errno == ENOTSUP)
+    FAIL_RET ("waitid WNOHANG on stopped: %m");
+  TEST_COMPARE (fail, 0);
+  TEST_COMPARE (info.si_signo, SIGCHLD);
+  TEST_COMPARE (info.si_code, CLD_STOPPED);
+  TEST_COMPARE (info.si_status, SIGSTOP);
+  TEST_COMPARE (info.si_pid, pid);
 
-  expecting_sigchld = WCONTINUED != 0;
+  //expecting_sigchld = WCONTINUED != 0;
 
   if (kill (pid, SIGCONT) != 0)
-    {
-      printf ("kill (%d, SIGCONT): %m\n", pid);
-      RETURN (EXIT_FAILURE);
-    }
+    FAIL_RET ("kill (%d, SIGCONT): %m\n", pid);
 
   /* Wait for the child to have continued.  */
-  sleep (2);
+  support_process_state_wait (pid, process_state_sleeping);
 
 #if WCONTINUED != 0
-  if (expecting_sigchld)
-    {
-      printf ("no SIGCHLD seen for SIGCONT (optional)\n");
-      expecting_sigchld = 0;
-    }
-  else
-    CHECK_SIGCHLD ("continued (before waitid)", CLD_CONTINUED, SIGCONT);
+  {
+    sigset_t set;
+    sigemptyset (&set);
+    sigaddset (&set, SIGCHLD);
+    siginfo_t info;
+    TEST_COMPARE (sigwaitinfo (&set, &info), SIGCHLD);
+
+    TEST_COMPARE (info.si_signo, SIGCHLD);
+    TEST_COMPARE (info.si_code, CLD_CONTINUED);
+    TEST_COMPARE (info.si_status, SIGCONT);
+    TEST_COMPARE (info.si_pid, pid);
+  }
 
   info.si_signo = 0;		/* A successful call sets it to SIGCHLD.  */
   info.si_pid = -1;
   info.si_status = -1;
   fail = waitid (P_PID, pid, &info, WCONTINUED|WNOWAIT);
-  switch (fail)
-    {
-    default:
-      printf ("waitid WCONTINUED|WNOWAIT returned bogus value %d\n", fail);
-      RETURN (EXIT_FAILURE);
-    case -1:
-      printf ("waitid WCONTINUED|WNOWAIT on continued: %m\n");
-      RETURN (errno == ENOTSUP ? EXIT_SUCCESS : EXIT_FAILURE);
-    case 0:
-      if (info.si_signo != SIGCHLD)
-	{
-	  printf ("waitid WCONTINUED|WNOWAIT on continued signal %d\n",
-		  info.si_signo);
-	  RETURN (EXIT_FAILURE);
-	}
-      if (info.si_code != CLD_CONTINUED)
-	{
-	  printf ("waitid WCONTINUED|WNOWAIT on continued code %d\n",
-		  info.si_code);
-	  RETURN (EXIT_FAILURE);
-	}
-      if (info.si_status != SIGCONT)
-	{
-	  printf ("waitid WCONTINUED|WNOWAIT on continued status %d\n",
-		  info.si_status);
-	  RETURN (EXIT_FAILURE);
-	}
-      if (info.si_pid != pid)
-	{
-	  printf ("waitid WCONTINUED|WNOWAIT on continued pid %d != %d\n",
-		  info.si_pid, pid);
-	  RETURN (EXIT_FAILURE);
-	}
-    }
+  if (fail == -1 && errno == ENOTSUP)
+    FAIL_RET ("waitid WCONTINUED|WNOWAIT on continued: %m");
+  TEST_COMPARE (fail, 0);
+  TEST_COMPARE (info.si_signo, SIGCHLD);
+  TEST_COMPARE (info.si_code, CLD_CONTINUED);
+  TEST_COMPARE (info.si_status, SIGCONT);
+  TEST_COMPARE (info.si_pid, pid);
 
   /* That should leave the CLD_CONTINUED state waiting to be seen again.  */
   info.si_signo = 0;		/* A successful call sets it to SIGCHLD.  */
   info.si_pid = -1;
   info.si_status = -1;
   fail = waitid (P_PID, pid, &info, WCONTINUED);
-  switch (fail)
-    {
-    default:
-      printf ("waitid WCONTINUED returned bogus value %d\n", fail);
-      RETURN (EXIT_FAILURE);
-    case -1:
-      printf ("waitid WCONTINUED on continued: %m\n");
-      RETURN (errno == ENOTSUP ? EXIT_SUCCESS : EXIT_FAILURE);
-    case 0:
-      if (info.si_signo != SIGCHLD)
-	{
-	  printf ("waitid WCONTINUED on continued signal %d\n", info.si_signo);
-	  RETURN (EXIT_FAILURE);
-	}
-      if (info.si_code != CLD_CONTINUED)
-	{
-	  printf ("waitid WCONTINUED on continued code %d\n", info.si_code);
-	  RETURN (EXIT_FAILURE);
-	}
-      if (info.si_status != SIGCONT)
-	{
-	  printf ("waitid WCONTINUED on continued status %d\n",
-		  info.si_status);
-	  RETURN (EXIT_FAILURE);
-	}
-      if (info.si_pid != pid)
-	{
-	  printf ("waitid WCONTINUED on continued pid %d != %d\n",
-		  info.si_pid, pid);
-	  RETURN (EXIT_FAILURE);
-	}
-    }
+  if (fail == -1 && errno == ENOTSUP)
+    FAIL_RET ("waitid WCONTINUED on continued: %m");
+  TEST_COMPARE (fail, 0);
+  TEST_COMPARE (info.si_signo, SIGCHLD);
+  TEST_COMPARE (info.si_code, CLD_CONTINUED);
+  TEST_COMPARE (info.si_status, SIGCONT);
+  TEST_COMPARE (info.si_pid, pid);
 
   /* Now try a wait that should not succeed.  */
   info.si_signo = 0;		/* A successful call sets it to SIGCHLD.  */
   fail = waitid (P_PID, pid, &info, WCONTINUED|WNOHANG);
-  switch (fail)
-    {
-    default:
-      printf ("waitid returned bogus value %d\n", fail);
-      RETURN (EXIT_FAILURE);
-    case -1:
-      printf ("waitid WCONTINUED|WNOHANG on waited continued: %m\n");
-      RETURN (errno == ENOTSUP ? EXIT_SUCCESS : EXIT_FAILURE);
-    case 0:
-      if (info.si_signo == 0)
-	break;
-      if (info.si_signo == SIGCHLD)
-	printf ("waitid WCONTINUED|WNOHANG on waited continued status %d\n",
-		info.si_status);
-      else
-	printf ("waitid WCONTINUED|WNOHANG on waited continued signal %d\n",
-		info.si_signo);
-      RETURN (EXIT_FAILURE);
-    }
+  if (fail == -1 && errno == ENOTSUP)
+    FAIL_RET ("waitid WCONTINUED|WNOHANG on waited continued: %m");
+  TEST_COMPARE (fail, 0);
+  TEST_COMPARE (info.si_signo, 0);
 
   /* Now stop him again and test waitpid with WCONTINUED.  */
-  expecting_sigchld = 1;
+  //expecting_sigchld = 1;
   if (kill (pid, SIGSTOP) != 0)
-    {
-      printf ("kill (%d, SIGSTOP): %m\n", pid);
-      RETURN (EXIT_FAILURE);
-    }
+    FAIL_RET ("kill (%d, SIGSTOP): %m\n", pid);
 
-  /* Give the child a chance to stop.  The waitpid call below will block
-     until it has stopped, but if we are real quick and enter the waitpid
-     system call before the SIGCHLD has been generated, then it will be
-     discarded and never delivered.  */
-  sleep (3);
+  /* Wait the child stop.  The waitid call below will block until it has
+     stopped, but if we are real quick and enter the waitid system call
+     before the SIGCHLD has been generated, then it will be discarded and
+     never delivered.  */
+  support_process_state_wait (pid, stop_state);
 
-  pid_t wpid = waitpid (pid, &fail, WUNTRACED);
-  if (wpid < 0)
-    {
-      printf ("waitpid WUNTRACED on stopped: %m\n");
-      RETURN (EXIT_FAILURE);
-    }
-  else if (wpid != pid)
-    {
-      printf ("waitpid WUNTRACED on stopped returned %d != %d (status %x)\n",
-	      wpid, pid, fail);
-      RETURN (EXIT_FAILURE);
-    }
-  else if (!WIFSTOPPED (fail) || WIFSIGNALED (fail) || WIFEXITED (fail)
-	   || WIFCONTINUED (fail) || WSTOPSIG (fail) != SIGSTOP)
-    {
-      printf ("waitpid WUNTRACED on stopped: status %x\n", fail);
-      RETURN (EXIT_FAILURE);
-    }
-  CHECK_SIGCHLD ("stopped (after waitpid)", CLD_STOPPED, SIGSTOP);
+  fail = waitid (type, pid, &info, WEXITED|WSTOPPED);
+  TEST_COMPARE (fail, 0);
+  TEST_COMPARE (info.si_signo, SIGCHLD);
+  TEST_COMPARE (info.si_code, CLD_STOPPED);
+  TEST_COMPARE (info.si_status, SIGSTOP);
+  TEST_COMPARE (info.si_pid, pid);
+
+  check_sigchld (CLD_STOPPED, SIGSTOP, pid);
 
-  expecting_sigchld = 1;
   if (kill (pid, SIGCONT) != 0)
-    {
-      printf ("kill (%d, SIGCONT): %m\n", pid);
-      RETURN (EXIT_FAILURE);
-    }
+    FAIL_RET ("kill (%d, SIGCONT): %m\n", pid);
 
   /* Wait for the child to have continued.  */
-  sleep (2);
+  support_process_state_wait (pid, process_state_sleeping);
 
-  if (expecting_sigchld)
-    {
-      printf ("no SIGCHLD seen for SIGCONT (optional)\n");
-      expecting_sigchld = 0;
-    }
-  else
-    CHECK_SIGCHLD ("continued (before waitpid)", CLD_CONTINUED, SIGCONT);
+  check_sigchld (CLD_CONTINUED, SIGCONT, pid);
 
-  wpid = waitpid (pid, &fail, WCONTINUED);
-  if (wpid < 0)
-    {
-      if (errno == EINVAL)
-	printf ("waitpid does not support WCONTINUED\n");
-      else
-	{
-	  printf ("waitpid WCONTINUED on continued: %m\n");
-	  RETURN (EXIT_FAILURE);
-	}
-    }
-  else if (wpid != pid)
-    {
-      printf ("\
-waitpid WCONTINUED on continued returned %d != %d (status %x)\n",
-	     wpid, pid, fail);
-      RETURN (EXIT_FAILURE);
-    }
-  else if (WIFSTOPPED (fail) || WIFSIGNALED (fail) || WIFEXITED (fail)
-	   || !WIFCONTINUED (fail))
-    {
-      printf ("waitpid WCONTINUED on continued: status %x\n", fail);
-      RETURN (EXIT_FAILURE);
-    }
+  fail = waitid (type, pid, &info, WCONTINUED);
+  TEST_COMPARE (fail, 0);
+  TEST_COMPARE (info.si_signo, SIGCHLD);
+  TEST_COMPARE (info.si_code, CLD_CONTINUED);
+  TEST_COMPARE (info.si_status, SIGCONT);
+  TEST_COMPARE (info.si_pid, pid);
 #endif
 
-  expecting_sigchld = 1;
-
   /* Die, child, die!  */
   if (kill (pid, SIGKILL) != 0)
-    {
-      printf ("kill (%d, SIGKILL): %m\n", pid);
-      RETURN (EXIT_FAILURE);
-    }
+    FAIL_RET ("kill (%d, SIGKILL): %m\n", pid);
 
 #ifdef WNOWAIT
   info.si_signo = 0;		/* A successful call sets it to SIGCHLD.  */
   info.si_pid = -1;
   info.si_status = -1;
-  fail = waitid (P_PID, pid, &info, WEXITED|WNOWAIT);
-  switch (fail)
-    {
-    default:
-      printf ("waitid WNOWAIT returned bogus value %d\n", fail);
-      RETURN (EXIT_FAILURE);
-    case -1:
-      printf ("waitid WNOWAIT on killed: %m\n");
-      RETURN (errno == ENOTSUP ? EXIT_SUCCESS : EXIT_FAILURE);
-    case 0:
-      if (info.si_signo != SIGCHLD)
-	{
-	  printf ("waitid WNOWAIT on killed signal %d\n", info.si_signo);
-	  RETURN (EXIT_FAILURE);
-	}
-      if (info.si_code != CLD_KILLED)
-	{
-	  printf ("waitid WNOWAIT on killed code %d\n", info.si_code);
-	  RETURN (EXIT_FAILURE);
-	}
-      if (info.si_status != SIGKILL)
-	{
-	  printf ("waitid WNOWAIT on killed status %d\n", info.si_status);
-	  RETURN (EXIT_FAILURE);
-	}
-      if (info.si_pid != pid)
-	{
-	  printf ("waitid WNOWAIT on killed pid %d != %d\n", info.si_pid, pid);
-	  RETURN (EXIT_FAILURE);
-	}
-    }
+  fail = waitid (type, pid, &info, WEXITED|WNOWAIT);
+  if (fail == -1 && errno == ENOTSUP)
+    FAIL_RET ("waitid WNOHANG on killed: %m");
+  TEST_COMPARE (fail, 0);
+  TEST_COMPARE (info.si_signo, SIGCHLD);
+  TEST_COMPARE (info.si_code, CLD_KILLED);
+  TEST_COMPARE (info.si_status, SIGKILL);
+  TEST_COMPARE (info.si_pid, pid);
 #else
-  /* Allow enough time to be sure the child died; we didn't synchronize.  */
-  sleep (2);
+  support_process_state_wait (pid, process_state_zombie);
 #endif
-
-  CHECK_SIGCHLD ("killed", CLD_KILLED, SIGKILL);
+  check_sigchld (CLD_KILLED, SIGKILL, pid);
 
   info.si_signo = 0;		/* A successful call sets it to SIGCHLD.  */
   info.si_pid = -1;
   info.si_status = -1;
-  fail = waitid (P_PID, pid, &info, WEXITED|WNOHANG);
-  switch (fail)
-    {
-    default:
-      printf ("waitid WNOHANG returned bogus value %d\n", fail);
-      RETURN (EXIT_FAILURE);
-    case -1:
-      printf ("waitid WNOHANG on killed: %m\n");
-      RETURN (EXIT_FAILURE);
-    case 0:
-      if (info.si_signo != SIGCHLD)
-	{
-	  printf ("waitid WNOHANG on killed signal %d\n", info.si_signo);
-	  RETURN (EXIT_FAILURE);
-	}
-      if (info.si_code != CLD_KILLED)
-	{
-	  printf ("waitid WNOHANG on killed code %d\n", info.si_code);
-	  RETURN (EXIT_FAILURE);
-	}
-      if (info.si_status != SIGKILL)
-	{
-	  printf ("waitid WNOHANG on killed status %d\n", info.si_status);
-	  RETURN (EXIT_FAILURE);
-	}
-      if (info.si_pid != pid)
-	{
-	  printf ("waitid WNOHANG on killed pid %d != %d\n", info.si_pid, pid);
-	  RETURN (EXIT_FAILURE);
-	}
-    }
+  fail = waitid (type, pid, &info, WEXITED | WNOHANG);
+  TEST_COMPARE (fail, 0);
+  TEST_COMPARE (info.si_signo, SIGCHLD);
+  TEST_COMPARE (info.si_code, CLD_KILLED);
+  TEST_COMPARE (info.si_status, SIGKILL);
+  TEST_COMPARE (info.si_pid, pid);
 
   fail = waitid (P_PID, pid, &info, WEXITED);
-  if (fail == -1)
-    {
-      if (errno != ECHILD)
-	{
-	  printf ("waitid WEXITED on killed: %m\n");
-	  RETURN (EXIT_FAILURE);
-	}
-    }
-  else
+  TEST_COMPARE (fail, -1);
+  TEST_COMPARE (errno, ECHILD);
+
+  return 0;
+}
+
+static int
+do_test_waitid (idtype_t type)
+{
+#ifdef SA_SIGINFO
+  {
+    struct sigaction sa;
+    sa.sa_flags = SA_SIGINFO | SA_RESTART;
+    sa.sa_sigaction = sigchld;
+    sigemptyset (&sa.sa_mask);
+    xsigaction (SIGCHLD, &sa, NULL);
+  }
+#endif
+
+  sigemptyset (&chldset);
+  sigaddset (&chldset, SIGCHLD);
+
+  /* The SIGCHLD shall has blocked at the time of the call to sigwait;
+     otherwise, the behavior is undefined.  */
+  sigprocmask (SIG_BLOCK, &chldset, NULL);
+
+  pid_t pid = xfork ();
+  if (pid == 0)
     {
-      printf ("waitid WEXITED returned bogus value %d\n", fail);
-      RETURN (EXIT_FAILURE);
+      test_child (type == P_PGID || type == P_ALL);
+      _exit (127);
     }
 
-#undef RETURN
- out:
-  if (spurious_sigchld)
-    status = EXIT_FAILURE;
-  signal (SIGCHLD, SIG_IGN);
+  int ret = do_test_waitd_common (type, pid);
+
+  xsignal (SIGCHLD, SIG_IGN);
   kill (pid, SIGKILL);		/* Make sure it's dead if we bailed early.  */
-  return status;
+  return ret;
+}
+
+static int
+do_test (void)
+{
+  int ret = 0;
+
+  ret |= do_test_waitid (P_PID);
+  ret |= do_test_waitid (P_PGID);
+  ret |= do_test_waitid (P_ALL);
+
+  return ret;
 }
 
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2 3/3] posix: Remove posix waitid
  2020-02-18 14:02 [PATCH v2 1/3] support: Add support_process_state_wait Adhemerval Zanella
  2020-02-18 14:02 ` [PATCH v2 2/3] posix: Refactor tst-waitid (BZ #14666) Adhemerval Zanella
@ 2020-02-18 14:02 ` Adhemerval Zanella
  2020-02-18 17:47   ` Adhemerval Zanella
  2020-02-18 15:17 ` [PATCH v2 1/3] support: Add support_process_state_wait Florian Weimer
  2 siblings, 1 reply; 12+ messages in thread
From: Adhemerval Zanella @ 2020-02-18 14:02 UTC (permalink / raw)
  To: libc-alpha

The POSIX waitid implementation is problematic in some ways:

  - It emulates using waitpid, which default implementation calls
    wait4 and wait4 returns ENOSYS as default.

  - Also by using waitpid it does not allod support the WNOWAIT,
    WEXITED, WSTOPPED, or WCONTINUED flag.  With current POSIX
    specification the flags are no longer marked as optional.

Also due BZ#23091 Hurd still uses the implementation, so it is moved
to as a Hurd arch-specific folder (with some minor cleanups).

Checked against a i686-gnu (run-built-tests=no)
---
 posix/tst-waitid.c                    | 14 +++---
 sysdeps/{posix => mach/hurd}/waitid.c | 70 ++++-----------------------
 2 files changed, 16 insertions(+), 68 deletions(-)
 rename sysdeps/{posix => mach/hurd}/waitid.c (65%)

diff --git a/posix/tst-waitid.c b/posix/tst-waitid.c
index 2331c42e66..380d807498 100644
--- a/posix/tst-waitid.c
+++ b/posix/tst-waitid.c
@@ -80,10 +80,10 @@ do_test_waitd_common (idtype_t type, pid_t pid)
 {
   /* Adding process_state_tracing_stop ('t') allows the test to work under
      trace programs such as ptrace.  */
-  enum process_state_t stop_state = process_state_stopped
-				    | process_state_tracing_stop;
+  enum support_process_state stop_state
+    = support_process_state_stopped | support_process_state_tracing_stop;
 
-  support_process_state_wait (pid, stop_state);
+  support_process_state_wait (pid, stop_state, NULL);
 
   check_sigchld (CLD_STOPPED, SIGSTOP, pid);
 
@@ -117,7 +117,7 @@ do_test_waitd_common (idtype_t type, pid_t pid)
     FAIL_RET ("kill (%d, SIGCONT): %m\n", pid);
 
   /* Wait for the child to have continued.  */
-  support_process_state_wait (pid, process_state_sleeping);
+  support_process_state_wait (pid, support_process_state_sleeping, NULL);
 
 #if WCONTINUED != 0
   {
@@ -175,7 +175,7 @@ do_test_waitd_common (idtype_t type, pid_t pid)
      stopped, but if we are real quick and enter the waitid system call
      before the SIGCHLD has been generated, then it will be discarded and
      never delivered.  */
-  support_process_state_wait (pid, stop_state);
+  support_process_state_wait (pid, stop_state, NULL);
 
   fail = waitid (type, pid, &info, WEXITED|WSTOPPED);
   TEST_COMPARE (fail, 0);
@@ -190,7 +190,7 @@ do_test_waitd_common (idtype_t type, pid_t pid)
     FAIL_RET ("kill (%d, SIGCONT): %m\n", pid);
 
   /* Wait for the child to have continued.  */
-  support_process_state_wait (pid, process_state_sleeping);
+  support_process_state_wait (pid, support_process_state_sleeping, NULL);
 
   check_sigchld (CLD_CONTINUED, SIGCONT, pid);
 
@@ -219,7 +219,7 @@ do_test_waitd_common (idtype_t type, pid_t pid)
   TEST_COMPARE (info.si_status, SIGKILL);
   TEST_COMPARE (info.si_pid, pid);
 #else
-  support_process_state_wait (pid, process_state_zombie);
+  support_process_state_wait (pid, support_process_state_zombie, NULL);
 #endif
   check_sigchld (CLD_KILLED, SIGKILL, pid);
 
diff --git a/sysdeps/posix/waitid.c b/sysdeps/mach/hurd/waitid.c
similarity index 65%
rename from sysdeps/posix/waitid.c
rename to sysdeps/mach/hurd/waitid.c
index f752076735..dce72339dd 100644
--- a/sysdeps/posix/waitid.c
+++ b/sysdeps/mach/hurd/waitid.c
@@ -17,25 +17,11 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <assert.h>
 #include <errno.h>
-#include <signal.h>
-#define __need_NULL
-#include <stddef.h>
 #include <sys/wait.h>
-#include <sys/types.h>
-#include <sysdep-cancel.h>
 
-
-#ifdef DO_WAITID
-# define OUR_WAITID DO_WAITID
-#elif !defined NO_DO_WAITID
-# define OUR_WAITID do_waitid
-#endif
-
-#ifdef OUR_WAITID
-static int
-OUR_WAITID (idtype_t idtype, id_t id, siginfo_t *infop, int options)
+int
+__waitid (idtype_t idtype, id_t id, siginfo_t *infop, int options)
 {
   pid_t pid, child;
   int status;
@@ -43,7 +29,7 @@ OUR_WAITID (idtype_t idtype, id_t id, siginfo_t *infop, int options)
   switch (idtype)
     {
     case P_PID:
-      if(id <= 0)
+      if (id <= 0)
 	goto invalid;
       pid = (pid_t) id;
       break;
@@ -72,31 +58,10 @@ OUR_WAITID (idtype_t idtype, id_t id, siginfo_t *infop, int options)
       return -1;
     }
 
-  /* This emulation using waitpid cannot support the waitid modes in which
-     we do not reap the child, or match only stopped and not dead children.  */
-  if (0
-#ifdef WNOWAIT
-      || (options & WNOWAIT)
-#endif
-#ifdef WEXITED
-      || ((options & (WEXITED|WSTOPPED|WCONTINUED))
-	  != (WEXITED | (options & WSTOPPED)))
-#endif
-      )
-    {
-      __set_errno (ENOTSUP);
-      return -1;
-    }
-
   /* Note the waitid() is a cancellation point.  But since we call
      waitpid() which itself is a cancellation point we do not have
      to do anything here.  */
-  child = __waitpid (pid, &status,
-		     options
-#ifdef WEXITED
-		     &~ WEXITED
-#endif
-		     );
+  child = __waitpid (pid, &status, options);
 
   if (child == -1)
     /* `waitpid' set `errno' for us.  */
@@ -104,9 +69,11 @@ OUR_WAITID (idtype_t idtype, id_t id, siginfo_t *infop, int options)
 
   if (child == 0)
     {
-      /* The WHOHANG bit in OPTIONS is set and there are children available
-	 but none has a status for us.  The XPG docs do not mention this
-	 case so we clear the `siginfo_t' struct and return successfully.  */
+      /* POSIX.1-2008, Technical Corrigendum 1 XSH/TC1-2008/0713 [153] states
+	 that if waitid returns because WNOHANG was specified and status is
+	 not available for any process specified by idtype and id, then the
+	 si_signo and si_pid members of the structure pointed to by infop
+	 shall be set to zero.  */
       infop->si_signo = 0;
       infop->si_code = 0;
       return 0;
@@ -132,27 +99,8 @@ OUR_WAITID (idtype_t idtype, id_t id, siginfo_t *infop, int options)
       infop->si_code = CLD_STOPPED;
       infop->si_status = WSTOPSIG (status);
     }
-#ifdef WIFCONTINUED
-  else if (WIFCONTINUED (status))
-    {
-      infop->si_code = CLD_CONTINUED;
-      infop->si_status = SIGCONT;
-    }
-#endif
-  else
-    /* Can't happen. */
-    assert (! "What?");
 
   return 0;
 }
-#endif
-
-
-int
-__waitid (idtype_t idtype, id_t id, siginfo_t *infop, int options)
-{
-  /* __waitpid should be a cancellation point.  */
-  return do_waitid (idtype, id, infop, options);
-}
 weak_alias (__waitid, waitid)
 strong_alias (__waitid, __libc_waitid)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/3] support: Add support_process_state_wait
  2020-02-18 14:02 [PATCH v2 1/3] support: Add support_process_state_wait Adhemerval Zanella
  2020-02-18 14:02 ` [PATCH v2 2/3] posix: Refactor tst-waitid (BZ #14666) Adhemerval Zanella
  2020-02-18 14:02 ` [PATCH v2 3/3] posix: Remove posix waitid Adhemerval Zanella
@ 2020-02-18 15:17 ` Florian Weimer
  2020-02-18 17:52   ` Adhemerval Zanella
  2 siblings, 1 reply; 12+ messages in thread
From: Florian Weimer @ 2020-02-18 15:17 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

> +/* Wait for process PID to reach state STATE.  It can be a combination of
> +   multiple possible states ('process_state_running | process_state_sleeping')
> +   where the function return when any of these state are observed.
> +   The timeout POLL_TS might be used to wait before polling the PID status
> +   information from the kernel.  A NULL value will set to use a default
> +   value (10000000 ns).
> +   For an invalid state not represented by SUPPORT_PROCESS_STATE, it fallbacks
> +   to a 2 second sleep.  */
> +void support_process_state_wait (pid_t pid, enum support_process_state state,
> +				 struct timespec *poll_ts);

The comment should say what happens if the timeout expires.  And I
believe the argument should be a const struct timespec *.  But I don't
see how controlling the poll interval is useful.

> diff --git a/support/xgetline.c b/support/xgetline.c
> new file mode 100644
> index 0000000000..5b010bcf56
> --- /dev/null
> +++ b/support/xgetline.c
> @@ -0,0 +1,34 @@
> +/* fopen with error checking.
> +   Copyright (C) 2016-2019 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <support/xstdio.h>
> +
> +#include <support/check.h>
> +#include <errno.h>
> +
> +ssize_t
> +xgetline (char **lineptr, size_t *n, FILE *stream)
> +{
> +  int old_errno = errno;
> +  errno = 0;
> +  ssize_t ret = getline (lineptr, n, stream);
> +  if (ret == -1 && errno != 0)
> +    FAIL_EXIT1 ("getline failed: %m");
> +  errno = old_errno;
> +  return ret;
> +}

I think it would be clearer to use ferror to check for errors.

Rest of the patch looks okay.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 2/3] posix: Refactor tst-waitid (BZ #14666)
  2020-02-18 14:02 ` [PATCH v2 2/3] posix: Refactor tst-waitid (BZ #14666) Adhemerval Zanella
@ 2020-02-18 17:47   ` Adhemerval Zanella
  2020-02-27 16:44     ` Adhemerval Zanella
  0 siblings, 1 reply; 12+ messages in thread
From: Adhemerval Zanella @ 2020-02-18 17:47 UTC (permalink / raw)
  To: libc-alpha



On 18/02/2020 11:02, Adhemerval Zanella wrote:
> Changes from previous version:
> 
>   - Use sigwaitinfo instead of global variables set by the signal handler.
> 
> --
> 
> The main changes are:
> 
>   - Adapt to libsupport.
>   - Synchronize the signal handler using atomics.
>   - Replace waitpid by waitid calls.
>   - Use support_process_state_wait to wait for child state.
>   - Add tests for P_PGID and P_ALL.
>   - Use sigwaitinfo instead of global state set by the signal handler.
> 
> Checked on x86_64-linux-gnu and i686-linux-gnu.

So I did a wrong rebase and the changes required for this patch ended up on 
the third on on this set. 

> ---
>  posix/tst-waitid.c | 561 ++++++++++++++-------------------------------
>  1 file changed, 166 insertions(+), 395 deletions(-)
> 
> diff --git a/posix/tst-waitid.c b/posix/tst-waitid.c
> index c4725489ea..2331c42e66 100644
> --- a/posix/tst-waitid.c
> +++ b/posix/tst-waitid.c
> @@ -22,13 +22,20 @@
>  #include <unistd.h>
>  #include <sys/wait.h>
>  #include <signal.h>
> +#include <time.h>
> +#include <stdatomic.h>
> +#include <stdbool.h>
> +
> +#include <support/xsignal.h>
> +#include <support/xunistd.h>
> +#include <support/check.h>
> +#include <support/process_state.h>
>  
>  static void
> -test_child (void)
> +test_child (bool setgroup)
>  {
> -  /* Wait a second to be sure the parent set his variables before we
> -     produce a SIGCHLD.  */
> -  sleep (1);
> +  if (setgroup)
> +    TEST_COMPARE (setpgid (0, 0), 0);
>  
>    /* First thing, we stop ourselves.  */
>    raise (SIGSTOP);
> @@ -44,475 +51,239 @@ test_child (void)
>  # define WSTOPPED	WUNTRACED
>  #endif
>  
> -static sig_atomic_t expecting_sigchld, spurious_sigchld;
> -#ifdef SA_SIGINFO
> -static siginfo_t sigchld_info;
> +/* Set with only SIGCHLD on do_test_waitid.  */
> +static sigset_t chldset;
>  
> +#ifdef SA_SIGINFO
>  static void
>  sigchld (int signo, siginfo_t *info, void *ctx)
>  {
> -  if (signo != SIGCHLD)
> -    {
> -      printf ("SIGCHLD handler got signal %d instead!\n", signo);
> -      _exit (EXIT_FAILURE);
> -    }
> -
> -  if (! expecting_sigchld)
> -    {
> -      spurious_sigchld = 1;
> -      printf ("spurious SIGCHLD: signo %d code %d status %d pid %d\n",
> -	      info->si_signo, info->si_code, info->si_status, info->si_pid);
> -    }
> -  else
> -    {
> -      sigchld_info = *info;
> -      expecting_sigchld = 0;
> -    }
>  }
> +#endif
>  
>  static void
> -check_sigchld (const char *phase, int *ok, int code, int status, pid_t pid)
> +check_sigchld (int code, int status, pid_t pid)
>  {
> -  if (expecting_sigchld)
> -    {
> -      printf ("missing SIGCHLD on %s\n", phase);
> -      *ok = EXIT_FAILURE;
> -      expecting_sigchld = 0;
> -      return;
> -    }
> +#ifdef SA_SIGINFO
> +  siginfo_t siginfo;
> +  TEST_COMPARE (sigwaitinfo (&chldset, &siginfo), SIGCHLD);
>  
> -  if (sigchld_info.si_signo != SIGCHLD)
> -    {
> -      printf ("SIGCHLD for %s signal %d\n", phase, sigchld_info.si_signo);
> -      *ok = EXIT_FAILURE;
> -    }
> -  if (sigchld_info.si_code != code)
> -    {
> -      printf ("SIGCHLD for %s code %d\n", phase, sigchld_info.si_code);
> -      *ok = EXIT_FAILURE;
> -    }
> -  if (sigchld_info.si_status != status)
> -    {
> -      printf ("SIGCHLD for %s status %d\n", phase, sigchld_info.si_status);
> -      *ok = EXIT_FAILURE;
> -    }
> -  if (sigchld_info.si_pid != pid)
> -    {
> -      printf ("SIGCHLD for %s pid %d\n", phase, sigchld_info.si_pid);
> -      *ok = EXIT_FAILURE;
> -    }
> -}
> -# define CHECK_SIGCHLD(phase, code_check, status_check) \
> -  check_sigchld ((phase), &status, (code_check), (status_check), pid)
> -#else
> -# define CHECK_SIGCHLD(phase, code, status) ((void) 0)
> +  TEST_COMPARE (siginfo.si_signo, SIGCHLD);
> +  TEST_COMPARE (siginfo.si_code, code);
> +  TEST_COMPARE (siginfo.si_status, status);
> +  TEST_COMPARE (siginfo.si_pid, pid);
>  #endif
> +}
>  
>  static int
> -do_test (int argc, char *argv[])
> +do_test_waitd_common (idtype_t type, pid_t pid)
>  {
> -#ifdef SA_SIGINFO
> -  struct sigaction sa;
> -  sa.sa_flags = SA_SIGINFO|SA_RESTART;
> -  sa.sa_sigaction = &sigchld;
> -  if (sigemptyset (&sa.sa_mask) < 0 || sigaction (SIGCHLD, &sa, NULL) < 0)
> -    {
> -      printf ("setting SIGCHLD handler: %m\n");
> -      return EXIT_FAILURE;
> -    }
> -#endif
> +  /* Adding process_state_tracing_stop ('t') allows the test to work under
> +     trace programs such as ptrace.  */
> +  enum process_state_t stop_state = process_state_stopped
> +				    | process_state_tracing_stop;

Here is should be clearly:

  enum support_process_state stop_state = support_process_state_stopped
                                         | support_process_state_tracing_stop;

>  
> -  expecting_sigchld = 1;
> +  support_process_state_wait (pid, stop_state);
>  
> -  pid_t pid = fork ();
> -  if (pid < 0)
> -    {
> -      printf ("fork: %m\n");
> -      return EXIT_FAILURE;
> -    }
> -  else if (pid == 0)
> -    {
> -      test_child ();
> -      _exit (127);
> -    }
> -
> -  int status = EXIT_SUCCESS;
> -#define RETURN(ok) \
> -    do { if (status == EXIT_SUCCESS) status = (ok); goto out; } while (0)
> -
> -  /* Give the child a chance to stop.  */
> -  sleep (3);
> -
> -  CHECK_SIGCHLD ("stopped (before waitid)", CLD_STOPPED, SIGSTOP);
> +  check_sigchld (CLD_STOPPED, SIGSTOP, pid);
>  
>    /* Now try a wait that should not succeed.  */
>    siginfo_t info;
> +  int fail;
> +
>    info.si_signo = 0;		/* A successful call sets it to SIGCHLD.  */
> -  int fail = waitid (P_PID, pid, &info, WEXITED|WCONTINUED|WNOHANG);
> -  switch (fail)
> -    {
> -    default:
> -      printf ("waitid returned bogus value %d\n", fail);
> -      RETURN (EXIT_FAILURE);
> -    case -1:
> -      printf ("waitid WNOHANG on stopped: %m\n");
> -      RETURN (errno == ENOTSUP ? EXIT_SUCCESS : EXIT_FAILURE);
> -    case 0:
> -      if (info.si_signo == 0)
> -	break;
> -      if (info.si_signo == SIGCHLD)
> -	printf ("waitid WNOHANG on stopped status %d\n", info.si_status);
> -      else
> -	printf ("waitid WNOHANG on stopped signal %d\n", info.si_signo);
> -      RETURN (EXIT_FAILURE);
> -    }
> +  fail = waitid (P_PID, pid, &info, WEXITED|WCONTINUED|WNOHANG);
> +  if (fail == -1 && errno == ENOTSUP)
> +    FAIL_RET ("waitid WNOHANG on stopped: %m");
> +  TEST_COMPARE (fail, 0);
> +  TEST_COMPARE (info.si_signo, 0);
>  
>    /* Next the wait that should succeed right away.  */
>    info.si_signo = 0;		/* A successful call sets it to SIGCHLD.  */
>    info.si_pid = -1;
>    info.si_status = -1;
>    fail = waitid (P_PID, pid, &info, WSTOPPED|WNOHANG);
> -  switch (fail)
> -    {
> -    default:
> -      printf ("waitid WSTOPPED|WNOHANG returned bogus value %d\n", fail);
> -      RETURN (EXIT_FAILURE);
> -    case -1:
> -      printf ("waitid WSTOPPED|WNOHANG on stopped: %m\n");
> -      RETURN (errno == ENOTSUP ? EXIT_SUCCESS : EXIT_FAILURE);
> -    case 0:
> -      if (info.si_signo != SIGCHLD)
> -	{
> -	  printf ("waitid WSTOPPED|WNOHANG on stopped signal %d\n",
> -		  info.si_signo);
> -	  RETURN (EXIT_FAILURE);
> -	}
> -      if (info.si_code != CLD_STOPPED)
> -	{
> -	  printf ("waitid WSTOPPED|WNOHANG on stopped code %d\n",
> -		  info.si_code);
> -	  RETURN (EXIT_FAILURE);
> -	}
> -      if (info.si_status != SIGSTOP)
> -	{
> -	  printf ("waitid WSTOPPED|WNOHANG on stopped status %d\n",
> -		  info.si_status);
> -	  RETURN (EXIT_FAILURE);
> -	}
> -      if (info.si_pid != pid)
> -	{
> -	  printf ("waitid WSTOPPED|WNOHANG on stopped pid %d != %d\n",
> -		  info.si_pid, pid);
> -	  RETURN (EXIT_FAILURE);
> -	}
> -    }
> +  if (fail == -1 && errno == ENOTSUP)
> +    FAIL_RET ("waitid WNOHANG on stopped: %m");
> +  TEST_COMPARE (fail, 0);
> +  TEST_COMPARE (info.si_signo, SIGCHLD);
> +  TEST_COMPARE (info.si_code, CLD_STOPPED);
> +  TEST_COMPARE (info.si_status, SIGSTOP);
> +  TEST_COMPARE (info.si_pid, pid);
>  
> -  expecting_sigchld = WCONTINUED != 0;
> +  //expecting_sigchld = WCONTINUED != 0;
>  
>    if (kill (pid, SIGCONT) != 0)
> -    {
> -      printf ("kill (%d, SIGCONT): %m\n", pid);
> -      RETURN (EXIT_FAILURE);
> -    }
> +    FAIL_RET ("kill (%d, SIGCONT): %m\n", pid);
>  
>    /* Wait for the child to have continued.  */
> -  sleep (2);
> +  support_process_state_wait (pid, process_state_sleeping);

And here it should be:

  support_process_state_wait (pid, support_process_state_sleeping);

>  
>  #if WCONTINUED != 0
> -  if (expecting_sigchld)
> -    {
> -      printf ("no SIGCHLD seen for SIGCONT (optional)\n");
> -      expecting_sigchld = 0;
> -    }
> -  else
> -    CHECK_SIGCHLD ("continued (before waitid)", CLD_CONTINUED, SIGCONT);
> +  {
> +    sigset_t set;
> +    sigemptyset (&set);
> +    sigaddset (&set, SIGCHLD);
> +    siginfo_t info;
> +    TEST_COMPARE (sigwaitinfo (&set, &info), SIGCHLD);
> +
> +    TEST_COMPARE (info.si_signo, SIGCHLD);
> +    TEST_COMPARE (info.si_code, CLD_CONTINUED);
> +    TEST_COMPARE (info.si_status, SIGCONT);
> +    TEST_COMPARE (info.si_pid, pid);
> +  }
>  
>    info.si_signo = 0;		/* A successful call sets it to SIGCHLD.  */
>    info.si_pid = -1;
>    info.si_status = -1;
>    fail = waitid (P_PID, pid, &info, WCONTINUED|WNOWAIT);
> -  switch (fail)
> -    {
> -    default:
> -      printf ("waitid WCONTINUED|WNOWAIT returned bogus value %d\n", fail);
> -      RETURN (EXIT_FAILURE);
> -    case -1:
> -      printf ("waitid WCONTINUED|WNOWAIT on continued: %m\n");
> -      RETURN (errno == ENOTSUP ? EXIT_SUCCESS : EXIT_FAILURE);
> -    case 0:
> -      if (info.si_signo != SIGCHLD)
> -	{
> -	  printf ("waitid WCONTINUED|WNOWAIT on continued signal %d\n",
> -		  info.si_signo);
> -	  RETURN (EXIT_FAILURE);
> -	}
> -      if (info.si_code != CLD_CONTINUED)
> -	{
> -	  printf ("waitid WCONTINUED|WNOWAIT on continued code %d\n",
> -		  info.si_code);
> -	  RETURN (EXIT_FAILURE);
> -	}
> -      if (info.si_status != SIGCONT)
> -	{
> -	  printf ("waitid WCONTINUED|WNOWAIT on continued status %d\n",
> -		  info.si_status);
> -	  RETURN (EXIT_FAILURE);
> -	}
> -      if (info.si_pid != pid)
> -	{
> -	  printf ("waitid WCONTINUED|WNOWAIT on continued pid %d != %d\n",
> -		  info.si_pid, pid);
> -	  RETURN (EXIT_FAILURE);
> -	}
> -    }
> +  if (fail == -1 && errno == ENOTSUP)
> +    FAIL_RET ("waitid WCONTINUED|WNOWAIT on continued: %m");
> +  TEST_COMPARE (fail, 0);
> +  TEST_COMPARE (info.si_signo, SIGCHLD);
> +  TEST_COMPARE (info.si_code, CLD_CONTINUED);
> +  TEST_COMPARE (info.si_status, SIGCONT);
> +  TEST_COMPARE (info.si_pid, pid);
>  
>    /* That should leave the CLD_CONTINUED state waiting to be seen again.  */
>    info.si_signo = 0;		/* A successful call sets it to SIGCHLD.  */
>    info.si_pid = -1;
>    info.si_status = -1;
>    fail = waitid (P_PID, pid, &info, WCONTINUED);
> -  switch (fail)
> -    {
> -    default:
> -      printf ("waitid WCONTINUED returned bogus value %d\n", fail);
> -      RETURN (EXIT_FAILURE);
> -    case -1:
> -      printf ("waitid WCONTINUED on continued: %m\n");
> -      RETURN (errno == ENOTSUP ? EXIT_SUCCESS : EXIT_FAILURE);
> -    case 0:
> -      if (info.si_signo != SIGCHLD)
> -	{
> -	  printf ("waitid WCONTINUED on continued signal %d\n", info.si_signo);
> -	  RETURN (EXIT_FAILURE);
> -	}
> -      if (info.si_code != CLD_CONTINUED)
> -	{
> -	  printf ("waitid WCONTINUED on continued code %d\n", info.si_code);
> -	  RETURN (EXIT_FAILURE);
> -	}
> -      if (info.si_status != SIGCONT)
> -	{
> -	  printf ("waitid WCONTINUED on continued status %d\n",
> -		  info.si_status);
> -	  RETURN (EXIT_FAILURE);
> -	}
> -      if (info.si_pid != pid)
> -	{
> -	  printf ("waitid WCONTINUED on continued pid %d != %d\n",
> -		  info.si_pid, pid);
> -	  RETURN (EXIT_FAILURE);
> -	}
> -    }
> +  if (fail == -1 && errno == ENOTSUP)
> +    FAIL_RET ("waitid WCONTINUED on continued: %m");
> +  TEST_COMPARE (fail, 0);
> +  TEST_COMPARE (info.si_signo, SIGCHLD);
> +  TEST_COMPARE (info.si_code, CLD_CONTINUED);
> +  TEST_COMPARE (info.si_status, SIGCONT);
> +  TEST_COMPARE (info.si_pid, pid);
>  
>    /* Now try a wait that should not succeed.  */
>    info.si_signo = 0;		/* A successful call sets it to SIGCHLD.  */
>    fail = waitid (P_PID, pid, &info, WCONTINUED|WNOHANG);
> -  switch (fail)
> -    {
> -    default:
> -      printf ("waitid returned bogus value %d\n", fail);
> -      RETURN (EXIT_FAILURE);
> -    case -1:
> -      printf ("waitid WCONTINUED|WNOHANG on waited continued: %m\n");
> -      RETURN (errno == ENOTSUP ? EXIT_SUCCESS : EXIT_FAILURE);
> -    case 0:
> -      if (info.si_signo == 0)
> -	break;
> -      if (info.si_signo == SIGCHLD)
> -	printf ("waitid WCONTINUED|WNOHANG on waited continued status %d\n",
> -		info.si_status);
> -      else
> -	printf ("waitid WCONTINUED|WNOHANG on waited continued signal %d\n",
> -		info.si_signo);
> -      RETURN (EXIT_FAILURE);
> -    }
> +  if (fail == -1 && errno == ENOTSUP)
> +    FAIL_RET ("waitid WCONTINUED|WNOHANG on waited continued: %m");
> +  TEST_COMPARE (fail, 0);
> +  TEST_COMPARE (info.si_signo, 0);
>  
>    /* Now stop him again and test waitpid with WCONTINUED.  */
> -  expecting_sigchld = 1;
> +  //expecting_sigchld = 1;
>    if (kill (pid, SIGSTOP) != 0)
> -    {
> -      printf ("kill (%d, SIGSTOP): %m\n", pid);
> -      RETURN (EXIT_FAILURE);
> -    }
> +    FAIL_RET ("kill (%d, SIGSTOP): %m\n", pid);
>  
> -  /* Give the child a chance to stop.  The waitpid call below will block
> -     until it has stopped, but if we are real quick and enter the waitpid
> -     system call before the SIGCHLD has been generated, then it will be
> -     discarded and never delivered.  */
> -  sleep (3);
> +  /* Wait the child stop.  The waitid call below will block until it has
> +     stopped, but if we are real quick and enter the waitid system call
> +     before the SIGCHLD has been generated, then it will be discarded and
> +     never delivered.  */
> +  support_process_state_wait (pid, stop_state);
>  
> -  pid_t wpid = waitpid (pid, &fail, WUNTRACED);
> -  if (wpid < 0)
> -    {
> -      printf ("waitpid WUNTRACED on stopped: %m\n");
> -      RETURN (EXIT_FAILURE);
> -    }
> -  else if (wpid != pid)
> -    {
> -      printf ("waitpid WUNTRACED on stopped returned %d != %d (status %x)\n",
> -	      wpid, pid, fail);
> -      RETURN (EXIT_FAILURE);
> -    }
> -  else if (!WIFSTOPPED (fail) || WIFSIGNALED (fail) || WIFEXITED (fail)
> -	   || WIFCONTINUED (fail) || WSTOPSIG (fail) != SIGSTOP)
> -    {
> -      printf ("waitpid WUNTRACED on stopped: status %x\n", fail);
> -      RETURN (EXIT_FAILURE);
> -    }
> -  CHECK_SIGCHLD ("stopped (after waitpid)", CLD_STOPPED, SIGSTOP);
> +  fail = waitid (type, pid, &info, WEXITED|WSTOPPED);
> +  TEST_COMPARE (fail, 0);
> +  TEST_COMPARE (info.si_signo, SIGCHLD);
> +  TEST_COMPARE (info.si_code, CLD_STOPPED);
> +  TEST_COMPARE (info.si_status, SIGSTOP);
> +  TEST_COMPARE (info.si_pid, pid);
> +
> +  check_sigchld (CLD_STOPPED, SIGSTOP, pid);
>  
> -  expecting_sigchld = 1;
>    if (kill (pid, SIGCONT) != 0)
> -    {
> -      printf ("kill (%d, SIGCONT): %m\n", pid);
> -      RETURN (EXIT_FAILURE);
> -    }
> +    FAIL_RET ("kill (%d, SIGCONT): %m\n", pid);
>  
>    /* Wait for the child to have continued.  */
> -  sleep (2);
> +  support_process_state_wait (pid, process_state_sleeping);

And here it shold be:

  support_process_state_wait (pid, support_process_state_sleeping);

>  
> -  if (expecting_sigchld)
> -    {
> -      printf ("no SIGCHLD seen for SIGCONT (optional)\n");
> -      expecting_sigchld = 0;
> -    }
> -  else
> -    CHECK_SIGCHLD ("continued (before waitpid)", CLD_CONTINUED, SIGCONT);
> +  check_sigchld (CLD_CONTINUED, SIGCONT, pid);
>  
> -  wpid = waitpid (pid, &fail, WCONTINUED);
> -  if (wpid < 0)
> -    {
> -      if (errno == EINVAL)
> -	printf ("waitpid does not support WCONTINUED\n");
> -      else
> -	{
> -	  printf ("waitpid WCONTINUED on continued: %m\n");
> -	  RETURN (EXIT_FAILURE);
> -	}
> -    }
> -  else if (wpid != pid)
> -    {
> -      printf ("\
> -waitpid WCONTINUED on continued returned %d != %d (status %x)\n",
> -	     wpid, pid, fail);
> -      RETURN (EXIT_FAILURE);
> -    }
> -  else if (WIFSTOPPED (fail) || WIFSIGNALED (fail) || WIFEXITED (fail)
> -	   || !WIFCONTINUED (fail))
> -    {
> -      printf ("waitpid WCONTINUED on continued: status %x\n", fail);
> -      RETURN (EXIT_FAILURE);
> -    }
> +  fail = waitid (type, pid, &info, WCONTINUED);
> +  TEST_COMPARE (fail, 0);
> +  TEST_COMPARE (info.si_signo, SIGCHLD);
> +  TEST_COMPARE (info.si_code, CLD_CONTINUED);
> +  TEST_COMPARE (info.si_status, SIGCONT);
> +  TEST_COMPARE (info.si_pid, pid);
>  #endif
>  
> -  expecting_sigchld = 1;
> -
>    /* Die, child, die!  */
>    if (kill (pid, SIGKILL) != 0)
> -    {
> -      printf ("kill (%d, SIGKILL): %m\n", pid);
> -      RETURN (EXIT_FAILURE);
> -    }
> +    FAIL_RET ("kill (%d, SIGKILL): %m\n", pid);
>  
>  #ifdef WNOWAIT
>    info.si_signo = 0;		/* A successful call sets it to SIGCHLD.  */
>    info.si_pid = -1;
>    info.si_status = -1;
> -  fail = waitid (P_PID, pid, &info, WEXITED|WNOWAIT);
> -  switch (fail)
> -    {
> -    default:
> -      printf ("waitid WNOWAIT returned bogus value %d\n", fail);
> -      RETURN (EXIT_FAILURE);
> -    case -1:
> -      printf ("waitid WNOWAIT on killed: %m\n");
> -      RETURN (errno == ENOTSUP ? EXIT_SUCCESS : EXIT_FAILURE);
> -    case 0:
> -      if (info.si_signo != SIGCHLD)
> -	{
> -	  printf ("waitid WNOWAIT on killed signal %d\n", info.si_signo);
> -	  RETURN (EXIT_FAILURE);
> -	}
> -      if (info.si_code != CLD_KILLED)
> -	{
> -	  printf ("waitid WNOWAIT on killed code %d\n", info.si_code);
> -	  RETURN (EXIT_FAILURE);
> -	}
> -      if (info.si_status != SIGKILL)
> -	{
> -	  printf ("waitid WNOWAIT on killed status %d\n", info.si_status);
> -	  RETURN (EXIT_FAILURE);
> -	}
> -      if (info.si_pid != pid)
> -	{
> -	  printf ("waitid WNOWAIT on killed pid %d != %d\n", info.si_pid, pid);
> -	  RETURN (EXIT_FAILURE);
> -	}
> -    }
> +  fail = waitid (type, pid, &info, WEXITED|WNOWAIT);
> +  if (fail == -1 && errno == ENOTSUP)
> +    FAIL_RET ("waitid WNOHANG on killed: %m");
> +  TEST_COMPARE (fail, 0);
> +  TEST_COMPARE (info.si_signo, SIGCHLD);
> +  TEST_COMPARE (info.si_code, CLD_KILLED);
> +  TEST_COMPARE (info.si_status, SIGKILL);
> +  TEST_COMPARE (info.si_pid, pid);
>  #else
> -  /* Allow enough time to be sure the child died; we didn't synchronize.  */
> -  sleep (2);
> +  support_process_state_wait (pid, process_state_zombie);

And finally it should be:

  support_process_state_wait (pid, support_process_state_zombie);

>  #endif
> -
> -  CHECK_SIGCHLD ("killed", CLD_KILLED, SIGKILL);
> +  check_sigchld (CLD_KILLED, SIGKILL, pid);
>  
>    info.si_signo = 0;		/* A successful call sets it to SIGCHLD.  */
>    info.si_pid = -1;
>    info.si_status = -1;
> -  fail = waitid (P_PID, pid, &info, WEXITED|WNOHANG);
> -  switch (fail)
> -    {
> -    default:
> -      printf ("waitid WNOHANG returned bogus value %d\n", fail);
> -      RETURN (EXIT_FAILURE);
> -    case -1:
> -      printf ("waitid WNOHANG on killed: %m\n");
> -      RETURN (EXIT_FAILURE);
> -    case 0:
> -      if (info.si_signo != SIGCHLD)
> -	{
> -	  printf ("waitid WNOHANG on killed signal %d\n", info.si_signo);
> -	  RETURN (EXIT_FAILURE);
> -	}
> -      if (info.si_code != CLD_KILLED)
> -	{
> -	  printf ("waitid WNOHANG on killed code %d\n", info.si_code);
> -	  RETURN (EXIT_FAILURE);
> -	}
> -      if (info.si_status != SIGKILL)
> -	{
> -	  printf ("waitid WNOHANG on killed status %d\n", info.si_status);
> -	  RETURN (EXIT_FAILURE);
> -	}
> -      if (info.si_pid != pid)
> -	{
> -	  printf ("waitid WNOHANG on killed pid %d != %d\n", info.si_pid, pid);
> -	  RETURN (EXIT_FAILURE);
> -	}
> -    }
> +  fail = waitid (type, pid, &info, WEXITED | WNOHANG);
> +  TEST_COMPARE (fail, 0);
> +  TEST_COMPARE (info.si_signo, SIGCHLD);
> +  TEST_COMPARE (info.si_code, CLD_KILLED);
> +  TEST_COMPARE (info.si_status, SIGKILL);
> +  TEST_COMPARE (info.si_pid, pid);
>  
>    fail = waitid (P_PID, pid, &info, WEXITED);
> -  if (fail == -1)
> -    {
> -      if (errno != ECHILD)
> -	{
> -	  printf ("waitid WEXITED on killed: %m\n");
> -	  RETURN (EXIT_FAILURE);
> -	}
> -    }
> -  else
> +  TEST_COMPARE (fail, -1);
> +  TEST_COMPARE (errno, ECHILD);
> +
> +  return 0;
> +}
> +
> +static int
> +do_test_waitid (idtype_t type)
> +{
> +#ifdef SA_SIGINFO
> +  {
> +    struct sigaction sa;
> +    sa.sa_flags = SA_SIGINFO | SA_RESTART;
> +    sa.sa_sigaction = sigchld;
> +    sigemptyset (&sa.sa_mask);
> +    xsigaction (SIGCHLD, &sa, NULL);
> +  }
> +#endif
> +
> +  sigemptyset (&chldset);
> +  sigaddset (&chldset, SIGCHLD);
> +
> +  /* The SIGCHLD shall has blocked at the time of the call to sigwait;
> +     otherwise, the behavior is undefined.  */
> +  sigprocmask (SIG_BLOCK, &chldset, NULL);
> +
> +  pid_t pid = xfork ();
> +  if (pid == 0)
>      {
> -      printf ("waitid WEXITED returned bogus value %d\n", fail);
> -      RETURN (EXIT_FAILURE);
> +      test_child (type == P_PGID || type == P_ALL);
> +      _exit (127);
>      }
>  
> -#undef RETURN
> - out:
> -  if (spurious_sigchld)
> -    status = EXIT_FAILURE;
> -  signal (SIGCHLD, SIG_IGN);
> +  int ret = do_test_waitd_common (type, pid);
> +
> +  xsignal (SIGCHLD, SIG_IGN);
>    kill (pid, SIGKILL);		/* Make sure it's dead if we bailed early.  */
> -  return status;
> +  return ret;
> +}
> +
> +static int
> +do_test (void)
> +{
> +  int ret = 0;
> +
> +  ret |= do_test_waitid (P_PID);
> +  ret |= do_test_waitid (P_PGID);
> +  ret |= do_test_waitid (P_ALL);
> +
> +  return ret;
>  }
>  
> -#include "../test-skeleton.c"
> +#include <support/test-driver.c>
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 3/3] posix: Remove posix waitid
  2020-02-18 14:02 ` [PATCH v2 3/3] posix: Remove posix waitid Adhemerval Zanella
@ 2020-02-18 17:47   ` Adhemerval Zanella
  2020-02-27 16:45     ` Adhemerval Zanella
  0 siblings, 1 reply; 12+ messages in thread
From: Adhemerval Zanella @ 2020-02-18 17:47 UTC (permalink / raw)
  To: libc-alpha



On 18/02/2020 11:02, Adhemerval Zanella wrote:
> The POSIX waitid implementation is problematic in some ways:
> 
>   - It emulates using waitpid, which default implementation calls
>     wait4 and wait4 returns ENOSYS as default.
> 
>   - Also by using waitpid it does not allod support the WNOWAIT,
>     WEXITED, WSTOPPED, or WCONTINUED flag.  With current POSIX
>     specification the flags are no longer marked as optional.
> 
> Also due BZ#23091 Hurd still uses the implementation, so it is moved
> to as a Hurd arch-specific folder (with some minor cleanups).
> 
> Checked against a i686-gnu (run-built-tests=no)
> ---
>  posix/tst-waitid.c                    | 14 +++---

Ok, the changes on tst-waitid.c shouldn't be in this patch, but rather
on the second one.

>  sysdeps/{posix => mach/hurd}/waitid.c | 70 ++++-----------------------
>  2 files changed, 16 insertions(+), 68 deletions(-)
>  rename sysdeps/{posix => mach/hurd}/waitid.c (65%)
> 
> diff --git a/posix/tst-waitid.c b/posix/tst-waitid.c
> index 2331c42e66..380d807498 100644
> --- a/posix/tst-waitid.c
> +++ b/posix/tst-waitid.c
> @@ -80,10 +80,10 @@ do_test_waitd_common (idtype_t type, pid_t pid)
>  {
>    /* Adding process_state_tracing_stop ('t') allows the test to work under
>       trace programs such as ptrace.  */
> -  enum process_state_t stop_state = process_state_stopped
> -				    | process_state_tracing_stop;
> +  enum support_process_state stop_state
> +    = support_process_state_stopped | support_process_state_tracing_stop;
>  
> -  support_process_state_wait (pid, stop_state);
> +  support_process_state_wait (pid, stop_state, NULL);
>  
>    check_sigchld (CLD_STOPPED, SIGSTOP, pid);
>  
> @@ -117,7 +117,7 @@ do_test_waitd_common (idtype_t type, pid_t pid)
>      FAIL_RET ("kill (%d, SIGCONT): %m\n", pid);
>  
>    /* Wait for the child to have continued.  */
> -  support_process_state_wait (pid, process_state_sleeping);
> +  support_process_state_wait (pid, support_process_state_sleeping, NULL);
>  
>  #if WCONTINUED != 0
>    {
> @@ -175,7 +175,7 @@ do_test_waitd_common (idtype_t type, pid_t pid)
>       stopped, but if we are real quick and enter the waitid system call
>       before the SIGCHLD has been generated, then it will be discarded and
>       never delivered.  */
> -  support_process_state_wait (pid, stop_state);
> +  support_process_state_wait (pid, stop_state, NULL);
>  
>    fail = waitid (type, pid, &info, WEXITED|WSTOPPED);
>    TEST_COMPARE (fail, 0);
> @@ -190,7 +190,7 @@ do_test_waitd_common (idtype_t type, pid_t pid)
>      FAIL_RET ("kill (%d, SIGCONT): %m\n", pid);
>  
>    /* Wait for the child to have continued.  */
> -  support_process_state_wait (pid, process_state_sleeping);
> +  support_process_state_wait (pid, support_process_state_sleeping, NULL);
>  
>    check_sigchld (CLD_CONTINUED, SIGCONT, pid);
>  
> @@ -219,7 +219,7 @@ do_test_waitd_common (idtype_t type, pid_t pid)
>    TEST_COMPARE (info.si_status, SIGKILL);
>    TEST_COMPARE (info.si_pid, pid);
>  #else
> -  support_process_state_wait (pid, process_state_zombie);
> +  support_process_state_wait (pid, support_process_state_zombie, NULL);
>  #endif
>    check_sigchld (CLD_KILLED, SIGKILL, pid);
>  
> diff --git a/sysdeps/posix/waitid.c b/sysdeps/mach/hurd/waitid.c
> similarity index 65%
> rename from sysdeps/posix/waitid.c
> rename to sysdeps/mach/hurd/waitid.c
> index f752076735..dce72339dd 100644
> --- a/sysdeps/posix/waitid.c
> +++ b/sysdeps/mach/hurd/waitid.c
> @@ -17,25 +17,11 @@
>     License along with the GNU C Library; if not, see
>     <https://www.gnu.org/licenses/>.  */
>  
> -#include <assert.h>
>  #include <errno.h>
> -#include <signal.h>
> -#define __need_NULL
> -#include <stddef.h>
>  #include <sys/wait.h>
> -#include <sys/types.h>
> -#include <sysdep-cancel.h>
>  
> -
> -#ifdef DO_WAITID
> -# define OUR_WAITID DO_WAITID
> -#elif !defined NO_DO_WAITID
> -# define OUR_WAITID do_waitid
> -#endif
> -
> -#ifdef OUR_WAITID
> -static int
> -OUR_WAITID (idtype_t idtype, id_t id, siginfo_t *infop, int options)
> +int
> +__waitid (idtype_t idtype, id_t id, siginfo_t *infop, int options)
>  {
>    pid_t pid, child;
>    int status;
> @@ -43,7 +29,7 @@ OUR_WAITID (idtype_t idtype, id_t id, siginfo_t *infop, int options)
>    switch (idtype)
>      {
>      case P_PID:
> -      if(id <= 0)
> +      if (id <= 0)
>  	goto invalid;
>        pid = (pid_t) id;
>        break;
> @@ -72,31 +58,10 @@ OUR_WAITID (idtype_t idtype, id_t id, siginfo_t *infop, int options)
>        return -1;
>      }
>  
> -  /* This emulation using waitpid cannot support the waitid modes in which
> -     we do not reap the child, or match only stopped and not dead children.  */
> -  if (0
> -#ifdef WNOWAIT
> -      || (options & WNOWAIT)
> -#endif
> -#ifdef WEXITED
> -      || ((options & (WEXITED|WSTOPPED|WCONTINUED))
> -	  != (WEXITED | (options & WSTOPPED)))
> -#endif
> -      )
> -    {
> -      __set_errno (ENOTSUP);
> -      return -1;
> -    }
> -
>    /* Note the waitid() is a cancellation point.  But since we call
>       waitpid() which itself is a cancellation point we do not have
>       to do anything here.  */
> -  child = __waitpid (pid, &status,
> -		     options
> -#ifdef WEXITED
> -		     &~ WEXITED
> -#endif
> -		     );
> +  child = __waitpid (pid, &status, options);
>  
>    if (child == -1)
>      /* `waitpid' set `errno' for us.  */
> @@ -104,9 +69,11 @@ OUR_WAITID (idtype_t idtype, id_t id, siginfo_t *infop, int options)
>  
>    if (child == 0)
>      {
> -      /* The WHOHANG bit in OPTIONS is set and there are children available
> -	 but none has a status for us.  The XPG docs do not mention this
> -	 case so we clear the `siginfo_t' struct and return successfully.  */
> +      /* POSIX.1-2008, Technical Corrigendum 1 XSH/TC1-2008/0713 [153] states
> +	 that if waitid returns because WNOHANG was specified and status is
> +	 not available for any process specified by idtype and id, then the
> +	 si_signo and si_pid members of the structure pointed to by infop
> +	 shall be set to zero.  */
>        infop->si_signo = 0;
>        infop->si_code = 0;
>        return 0;
> @@ -132,27 +99,8 @@ OUR_WAITID (idtype_t idtype, id_t id, siginfo_t *infop, int options)
>        infop->si_code = CLD_STOPPED;
>        infop->si_status = WSTOPSIG (status);
>      }
> -#ifdef WIFCONTINUED
> -  else if (WIFCONTINUED (status))
> -    {
> -      infop->si_code = CLD_CONTINUED;
> -      infop->si_status = SIGCONT;
> -    }
> -#endif
> -  else
> -    /* Can't happen. */
> -    assert (! "What?");
>  
>    return 0;
>  }
> -#endif
> -
> -
> -int
> -__waitid (idtype_t idtype, id_t id, siginfo_t *infop, int options)
> -{
> -  /* __waitpid should be a cancellation point.  */
> -  return do_waitid (idtype, id, infop, options);
> -}
>  weak_alias (__waitid, waitid)
>  strong_alias (__waitid, __libc_waitid)
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/3] support: Add support_process_state_wait
  2020-02-18 15:17 ` [PATCH v2 1/3] support: Add support_process_state_wait Florian Weimer
@ 2020-02-18 17:52   ` Adhemerval Zanella
  2020-02-18 17:54     ` Florian Weimer
  0 siblings, 1 reply; 12+ messages in thread
From: Adhemerval Zanella @ 2020-02-18 17:52 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha



On 18/02/2020 12:17, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> +/* Wait for process PID to reach state STATE.  It can be a combination of
>> +   multiple possible states ('process_state_running | process_state_sleeping')
>> +   where the function return when any of these state are observed.
>> +   The timeout POLL_TS might be used to wait before polling the PID status
>> +   information from the kernel.  A NULL value will set to use a default
>> +   value (10000000 ns).
>> +   For an invalid state not represented by SUPPORT_PROCESS_STATE, it fallbacks
>> +   to a 2 second sleep.  */
>> +void support_process_state_wait (pid_t pid, enum support_process_state state,
>> +				 struct timespec *poll_ts);
> 
> The comment should say what happens if the timeout expires.  And I
> believe the argument should be a const struct timespec *.  But I don't
> see how controlling the poll interval is useful.

Thinking twice the poll interval really does not add much here,
I have removed it.

> 
>> diff --git a/support/xgetline.c b/support/xgetline.c
>> new file mode 100644
>> index 0000000000..5b010bcf56
>> --- /dev/null
>> +++ b/support/xgetline.c
>> @@ -0,0 +1,34 @@
>> +/* fopen with error checking.
>> +   Copyright (C) 2016-2019 Free Software Foundation, Inc.
>> +   This file is part of the GNU C Library.
>> +
>> +   The GNU C Library is free software; you can redistribute it and/or
>> +   modify it under the terms of the GNU Lesser General Public
>> +   License as published by the Free Software Foundation; either
>> +   version 2.1 of the License, or (at your option) any later version.
>> +
>> +   The GNU C Library is distributed in the hope that it will be useful,
>> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
>> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> +   Lesser General Public License for more details.
>> +
>> +   You should have received a copy of the GNU Lesser General Public
>> +   License along with the GNU C Library; if not, see
>> +   <https://www.gnu.org/licenses/>.  */
>> +
>> +#include <support/xstdio.h>
>> +
>> +#include <support/check.h>
>> +#include <errno.h>
>> +
>> +ssize_t
>> +xgetline (char **lineptr, size_t *n, FILE *stream)
>> +{
>> +  int old_errno = errno;
>> +  errno = 0;
>> +  ssize_t ret = getline (lineptr, n, stream);
>> +  if (ret == -1 && errno != 0)
>> +    FAIL_EXIT1 ("getline failed: %m");
>> +  errno = old_errno;
>> +  return ret;
>> +}
> 
> I think it would be clearer to use ferror to check for errors.

Maybe: 

   if (ret == -1 || ferror (stream))
     ...

?

> 
> Rest of the patch looks okay.
> 
> Thanks,
> Florian
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/3] support: Add support_process_state_wait
  2020-02-18 17:52   ` Adhemerval Zanella
@ 2020-02-18 17:54     ` Florian Weimer
  2020-02-18 18:01       ` Adhemerval Zanella
  0 siblings, 1 reply; 12+ messages in thread
From: Florian Weimer @ 2020-02-18 17:54 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

>> I think it would be clearer to use ferror to check for errors.
>
> Maybe: 
>
>    if (ret == -1 || ferror (stream))
>      ...
>
> ?

I think you might get ret == -1 on EOF, too.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/3] support: Add support_process_state_wait
  2020-02-18 17:54     ` Florian Weimer
@ 2020-02-18 18:01       ` Adhemerval Zanella
  2020-02-18 18:07         ` Florian Weimer
  0 siblings, 1 reply; 12+ messages in thread
From: Adhemerval Zanella @ 2020-02-18 18:01 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha



On 18/02/2020 14:54, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>>> I think it would be clearer to use ferror to check for errors.
>>
>> Maybe: 
>>
>>    if (ret == -1 || ferror (stream))
>>      ...
>>
>> ?
> 
> I think you might get ret == -1 on EOF, too.

Indeed, so:

  if (!feof (stream) && ferror (stream))
    FAIL_EXIT1 ("getline failed: %m");

Should cover it.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 1/3] support: Add support_process_state_wait
  2020-02-18 18:01       ` Adhemerval Zanella
@ 2020-02-18 18:07         ` Florian Weimer
  0 siblings, 0 replies; 12+ messages in thread
From: Florian Weimer @ 2020-02-18 18:07 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

> On 18/02/2020 14:54, Florian Weimer wrote:
>> * Adhemerval Zanella:
>> 
>>>> I think it would be clearer to use ferror to check for errors.
>>>
>>> Maybe: 
>>>
>>>    if (ret == -1 || ferror (stream))
>>>      ...
>>>
>>> ?
>> 
>> I think you might get ret == -1 on EOF, too.
>
> Indeed, so:
>
>   if (!feof (stream) && ferror (stream))
>     FAIL_EXIT1 ("getline failed: %m");
>
> Should cover it.

Yes, I think so.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 2/3] posix: Refactor tst-waitid (BZ #14666)
  2020-02-18 17:47   ` Adhemerval Zanella
@ 2020-02-27 16:44     ` Adhemerval Zanella
  0 siblings, 0 replies; 12+ messages in thread
From: Adhemerval Zanella @ 2020-02-27 16:44 UTC (permalink / raw)
  To: libc-alpha



On 18/02/2020 14:47, Adhemerval Zanella wrote:
> 
> 
> On 18/02/2020 11:02, Adhemerval Zanella wrote:
>> Changes from previous version:
>>
>>   - Use sigwaitinfo instead of global variables set by the signal handler.
>>
>> --
>>
>> The main changes are:
>>
>>   - Adapt to libsupport.
>>   - Synchronize the signal handler using atomics.
>>   - Replace waitpid by waitid calls.
>>   - Use support_process_state_wait to wait for child state.
>>   - Add tests for P_PGID and P_ALL.
>>   - Use sigwaitinfo instead of global state set by the signal handler.
>>
>> Checked on x86_64-linux-gnu and i686-linux-gnu.
> 
> So I did a wrong rebase and the changes required for this patch ended up on 
> the third on on this set. 

I will commit this patch shortly if no one opposes it.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2 3/3] posix: Remove posix waitid
  2020-02-18 17:47   ` Adhemerval Zanella
@ 2020-02-27 16:45     ` Adhemerval Zanella
  0 siblings, 0 replies; 12+ messages in thread
From: Adhemerval Zanella @ 2020-02-27 16:45 UTC (permalink / raw)
  To: libc-alpha



On 18/02/2020 14:47, Adhemerval Zanella wrote:
> 
> 
> On 18/02/2020 11:02, Adhemerval Zanella wrote:
>> The POSIX waitid implementation is problematic in some ways:
>>
>>   - It emulates using waitpid, which default implementation calls
>>     wait4 and wait4 returns ENOSYS as default.
>>
>>   - Also by using waitpid it does not allod support the WNOWAIT,
>>     WEXITED, WSTOPPED, or WCONTINUED flag.  With current POSIX
>>     specification the flags are no longer marked as optional.
>>
>> Also due BZ#23091 Hurd still uses the implementation, so it is moved
>> to as a Hurd arch-specific folder (with some minor cleanups).
>>
>> Checked against a i686-gnu (run-built-tests=no)
>> ---
>>  posix/tst-waitid.c                    | 14 +++---
> 
> Ok, the changes on tst-waitid.c shouldn't be in this patch, but rather
> on the second one.


I will commit this patch shortly if no one opposes it.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-02-27 16:45 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-18 14:02 [PATCH v2 1/3] support: Add support_process_state_wait Adhemerval Zanella
2020-02-18 14:02 ` [PATCH v2 2/3] posix: Refactor tst-waitid (BZ #14666) Adhemerval Zanella
2020-02-18 17:47   ` Adhemerval Zanella
2020-02-27 16:44     ` Adhemerval Zanella
2020-02-18 14:02 ` [PATCH v2 3/3] posix: Remove posix waitid Adhemerval Zanella
2020-02-18 17:47   ` Adhemerval Zanella
2020-02-27 16:45     ` Adhemerval Zanella
2020-02-18 15:17 ` [PATCH v2 1/3] support: Add support_process_state_wait Florian Weimer
2020-02-18 17:52   ` Adhemerval Zanella
2020-02-18 17:54     ` Florian Weimer
2020-02-18 18:01       ` Adhemerval Zanella
2020-02-18 18:07         ` Florian Weimer

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 read-only IMAP folder(s) and NNTP newsgroup(s).