about summary refs log tree commit diff
path: root/nptl/tst-cancel7.c
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2017-06-08 15:39:03 -0400
committerZack Weinberg <zackw@panix.com>2017-06-08 15:39:03 -0400
commit5046dbb4a7eba5eccfd258f92f4735c9ffc8d069 (patch)
tree4470480d904b65cf14ca524f96f79eca818c3eaf /nptl/tst-cancel7.c
parent199fc19d3aaaf57944ef036e15904febe877fc93 (diff)
downloadglibc-5046dbb4a7eba5eccfd258f92f4735c9ffc8d069.tar.gz
glibc-5046dbb4a7eba5eccfd258f92f4735c9ffc8d069.tar.xz
glibc-5046dbb4a7eba5eccfd258f92f4735c9ffc8d069.zip
Prepare for radical source tree reorganization. zack/build-layout-experiment
All top-level files and directories are moved into a temporary storage
directory, REORG.TODO, except for files that will certainly still
exist in their current form at top level when we're done (COPYING,
COPYING.LIB, LICENSES, NEWS, README), all old ChangeLog files (which
are moved to the new directory OldChangeLogs, instead), and the
generated file INSTALL (which is just deleted; in the new order, there
will be no generated files checked into version control).
Diffstat (limited to 'nptl/tst-cancel7.c')
-rw-r--r--nptl/tst-cancel7.c209
1 files changed, 0 insertions, 209 deletions
diff --git a/nptl/tst-cancel7.c b/nptl/tst-cancel7.c
deleted file mode 100644
index 7cbe04f2e2..0000000000
--- a/nptl/tst-cancel7.c
+++ /dev/null
@@ -1,209 +0,0 @@
-/* Copyright (C) 2002-2017 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
-
-   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
-   <http://www.gnu.org/licenses/>.  */
-
-#include <errno.h>
-#include <fcntl.h>
-#include <pthread.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <getopt.h>
-
-#include <support/xthread.h>
-
-const char *command;
-const char *pidfile;
-char pidfilename[] = "/tmp/tst-cancel7-XXXXXX";
-
-static void *
-tf (void *arg)
-{
-  const char *args = " --direct --pidfile ";
-  char *cmd = alloca (strlen (command) + strlen (args)
-		      + strlen (pidfilename) + 1);
-
-  strcpy (stpcpy (stpcpy (cmd, command), args), pidfilename);
-  system (cmd);
-  /* This call should never return.  */
-  return NULL;
-}
-
-
-static void
-sl (void)
-{
-  FILE *f = fopen (pidfile, "w");
-  if (f == NULL)
-    exit (1);
-
-  fprintf (f, "%lld\n", (long long) getpid ());
-  fflush (f);
-
-  struct flock fl =
-    {
-      .l_type = F_WRLCK,
-      .l_start = 0,
-      .l_whence = SEEK_SET,
-      .l_len = 1
-    };
-  if (fcntl (fileno (f), F_SETLK, &fl) != 0)
-    exit (1);
-
-  sigset_t ss;
-  sigfillset (&ss);
-  sigsuspend (&ss);
-  exit (0);
-}
-
-
-static void
-do_prepare (int argc, char *argv[])
-{
-  if (command == NULL)
-    command = argv[0];
-
-  if (pidfile)
-    sl ();
-
-  int fd = mkstemp (pidfilename);
-  if (fd == -1)
-    {
-      puts ("mkstemp failed");
-      exit (1);
-    }
-
-  write (fd, " ", 1);
-  close (fd);
-}
-
-
-static int
-do_test (void)
-{
-  pthread_t th;
-  if (pthread_create (&th, NULL, tf, NULL) != 0)
-    {
-      puts ("pthread_create failed");
-      return 1;
-    }
-
-  do
-    sleep (1);
-  while (access (pidfilename, R_OK) != 0);
-
-  xpthread_cancel (th);
-  void *r = xpthread_join (th);
-
-  sleep (1);
-
-  FILE *f = fopen (pidfilename, "r+");
-  if (f == NULL)
-    {
-      puts ("no pidfile");
-      return 1;
-    }
-
-  long long ll;
-  if (fscanf (f, "%lld\n", &ll) != 1)
-    {
-      puts ("could not read pid");
-      unlink (pidfilename);
-      return 1;
-    }
-
-  struct flock fl =
-    {
-      .l_type = F_WRLCK,
-      .l_start = 0,
-      .l_whence = SEEK_SET,
-      .l_len = 1
-    };
-  if (fcntl (fileno (f), F_GETLK, &fl) != 0)
-    {
-      puts ("F_GETLK failed");
-      unlink (pidfilename);
-      return 1;
-    }
-
-  if (fl.l_type != F_UNLCK)
-    {
-      printf ("child %lld still running\n", (long long) fl.l_pid);
-      if (fl.l_pid == ll)
-	kill (fl.l_pid, SIGKILL);
-
-      unlink (pidfilename);
-      return 1;
-    }
-
-  fclose (f);
-
-  unlink (pidfilename);
-
-  return r != PTHREAD_CANCELED;
-}
-
-static void
-do_cleanup (void)
-{
-  FILE *f = fopen (pidfilename, "r+");
-  long long ll;
-
-  if (f != NULL && fscanf (f, "%lld\n", &ll) == 1)
-    {
-      struct flock fl =
-	{
-	  .l_type = F_WRLCK,
-	  .l_start = 0,
-	  .l_whence = SEEK_SET,
-	  .l_len = 1
-	};
-      if (fcntl (fileno (f), F_GETLK, &fl) == 0 && fl.l_type != F_UNLCK
-	  && fl.l_pid == ll)
-	kill (fl.l_pid, SIGKILL);
-
-      fclose (f);
-    }
-
-  unlink (pidfilename);
-}
-
-#define OPT_COMMAND	10000
-#define OPT_PIDFILE	10001
-#define CMDLINE_OPTIONS \
-  { "command", required_argument, NULL, OPT_COMMAND },	\
-  { "pidfile", required_argument, NULL, OPT_PIDFILE },
-static void
-cmdline_process (int c)
-{
-  switch (c)
-    {
-    case OPT_COMMAND:
-      command = optarg;
-      break;
-    case OPT_PIDFILE:
-      pidfile = optarg;
-      break;
-    }
-}
-#define CMDLINE_PROCESS cmdline_process
-#define CLEANUP_HANDLER do_cleanup
-#define PREPARE do_prepare
-#define TIMEOUT 5
-#include <support/test-driver.c>