/var/lib/pcp/testsuite/src/spawn.c is in pcp-testsuite 4.0.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | /*
* Process creation -- based upon MUSBUS ....
*
* fork()-n-exit() for child
*
* $Header: spawn.c,v 3.5 1993/07/02 21:17:11 kenj Exp $
*
* Yep! code from 1993.
*
* This code comes from the Musbus benchmark that was written by me
* and first released into the public domain circa 1984.
* - Ken McDonell, Jan 2018
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
int
main(int argc, char **argv)
{
int iter;
int slave;
int status;
if (argc != 2) {
printf("Usage: %s count\n", argv[0]);
exit(1);
}
iter = atoi(argv[1]);
while (iter-- > 0) {
if ((slave = fork()) == 0) {
/* slave .. boring */
#if debug
printf("fork OK\n");
#endif
exit(0);
} else if (slave < 0) {
/* woops ... */
printf("Fork failed at iteration %d\n", iter);
perror("Reason");
exit(2);
} else
wait(&status);
if (status != 0) {
printf("Bad wait status: 0x%x\n", status);
exit(2);
}
#if debug
printf("Child %d done.\n", slave);
#endif
}
exit(0);
}
|