gdb/python: don't allow the user to delete window title attributes
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / foll-vfork.c
index 933ce38b9549f213b27d6363b2ef14388c4b9a4d..2f6661d1a0bb1ebb38b31f20b45bda118024d102 100644 (file)
@@ -1,6 +1,6 @@
 /* This testcase is part of GDB, the GNU debugger.
 
-   Copyright 1997-2014 Free Software Foundation, Inc.
+   Copyright 1997-2021 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 #include <stdio.h>
 #include <unistd.h>
 
-int main (void)
+#include <limits.h>
+#include <string.h>
+
+int
+main (int argc, char ** argv)
 {
   int  pid;
 
-  pid = vfork ();
+  /* A statement before vfork to make sure a breakpoint on main isn't
+     set on vfork below.  */
+  pid = 1 + argc;
+  pid = vfork (); /* VFORK */
   if (pid == 0) {
+    char prog[PATH_MAX];
+    int len;
+
+    strcpy (prog, argv[0]);
+    len = strlen (prog);
+    /* Replace "foll-vfork" with "vforked-prog".  */
+    memcpy (prog + len - 10, "vforked-prog", 12);
+    prog[len + 2] = 0;
+
     printf ("I'm the child!\n");
-    execlp (BASEDIR "/vforked-prog", BASEDIR "/vforked-prog", (char *)0);
+    execlp (prog, prog, (char *) 0);
     perror ("exec failed");
     _exit (1);
   }
This page took 0.024633 seconds and 4 git commands to generate.