Changeset 2278
- Timestamp:
- Aug 14, 2005, 8:42:50 AM (20 years ago)
- Location:
- trunk/src/libctests/libc/smoketests
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libctests/libc/smoketests/fork-1.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r2277 r2278 7 7 * 8 8 * 9 * This file is part of kBuild.9 * This file is part of InnoTek LIBC. 10 10 * 11 * kBuildis free software; you can redistribute it and/or modify11 * InnoTek LIBC is free software; you can redistribute it and/or modify 12 12 * it under the terms of the GNU General Public License as published by 13 13 * the Free Software Foundation; either version 2 of the License, or 14 14 * (at your option) any later version. 15 15 * 16 * kBuildis distributed in the hope that it will be useful,16 * InnoTek LIBC is distributed in the hope that it will be useful, 17 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the … … 20 20 * 21 21 * You should have received a copy of the GNU General Public License 22 * along with kBuild; if not, write to the Free Software22 * along with InnoTek LIBC; if not, write to the Free Software 23 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 24 * -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/libctests/libc/smoketests/fork-exec-1.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r2277 r2278 43 43 { 44 44 if (argc == 2 && !strcmp(argv[1], "child")) 45 { 46 printf("fork-exec-1: %d: child of %d\n", getpid(), getppid()); 45 47 return 0; 48 } 49 printf("fork-exec-1: %d: %s, parent %d\n", getpid(), argc >= 2 ? argv[1] : "main", getppid()); 46 50 47 51 char *argv_child[3]; … … 49 53 argv_child[1] = "child"; 50 54 argv_child[2] = NULL; 51 int rc = spawnvp(P_WAIT, argv_child[0], argv_child); 52 if (rc) 55 if (argc != 2 || strcmp(argv[1], "2nd")) 53 56 { 54 printf("fork-exec-1: child1 failed! rc=%d\n", rc); 55 return 1; 57 int rc = spawnvp(P_WAIT, argv_child[0], argv_child); 58 if (rc) 59 { 60 printf("fork-exec-1: child1 failed! rc=%d\n", rc); 61 return 1; 62 } 56 63 } 57 64 58 65 /* 59 * Main process.66 * Fork children (three generations). 60 67 */ 61 68 pid_t pid = fork(); … … 67 74 if (pid == 0) 68 75 { 69 execvp(argv_child[0], argv_child); 76 if (argc == 2 && !strcmp(argv[1], "1st")) 77 { 78 printf("fork-exec-1: %d: 2nd fork, from %d\n", getpid(), getppid()); 79 argv_child[1] = "2nd"; 80 execvp(argv_child[0], argv_child); 81 } 82 else if (argc != 2 || strcmp(argv[1], "2nd")) 83 { 84 printf("fork-exec-1: %d: 1st fork, from %d\n", getpid(), getppid()); 85 argv_child[1] = "1st"; 86 execvp(argv_child[0], argv_child); 87 } 88 else 89 { 90 printf("fork-exec-1: %d: 3rd fork, from %d\n", getpid(), getppid()); 91 execvp(argv_child[0], argv_child); 92 } 70 93 printf("fork-exec-1: exec failed! errno=%d %m\n", errno); 71 94 return 1; -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.