blob: eef1d0e3b74bd5453bf7e99ed8581a2e23f75fb1 (
plain)
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
|
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <string.h>
#include <sys/prctl.h>
/*
* Small helper to create processes with predictable names/properties for ps tests.
*/
static void
handle_sigterm(int sig)
{
(void)sig;
exit(0);
}
int
main(int argc, char **argv)
{
if (argc < 2) {
fprintf(stderr, "usage: %s <name> [arg...]\n", argv[0]);
return (1);
}
/* Set name for /proc/self/comm (visible in ps -c) */
prctl(PR_SET_NAME, argv[1], 0, 0, 0);
signal(SIGTERM, handle_sigterm);
/* Busy wait in background to consume some CPU time if needed */
if (argc > 2 && strcmp(argv[2], "busy") == 0) {
while (1) {
/* Do nothing, just spin */
}
}
/* Normal idle wait */
while (1) {
pause();
}
return (0);
}
|