1 | /* Wait for process state. |
2 | Copyright (C) 2020-2023 Free Software Foundation, Inc. |
3 | This file is part of the GNU C Library. |
4 | |
5 | The GNU C Library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either |
8 | version 2.1 of the License, or (at your option) any later version. |
9 | |
10 | The GNU C Library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Lesser General Public License for more details. |
14 | |
15 | You should have received a copy of the GNU Lesser General Public |
16 | License along with the GNU C Library; if not, see |
17 | <https://www.gnu.org/licenses/>. */ |
18 | |
19 | #ifndef SUPPORT_PROCESS_STATE_H |
20 | #define SUPPORT_PROCESS_STATE_H |
21 | |
22 | #include <sys/types.h> |
23 | |
24 | enum support_process_state |
25 | { |
26 | support_process_state_running = 0x01, /* R (running). */ |
27 | support_process_state_sleeping = 0x02, /* S (sleeping). */ |
28 | support_process_state_disk_sleep = 0x04, /* D (disk sleep). */ |
29 | support_process_state_stopped = 0x08, /* T (stopped). */ |
30 | support_process_state_tracing_stop = 0x10, /* t (tracing stop). */ |
31 | support_process_state_dead = 0x20, /* X (dead). */ |
32 | support_process_state_zombie = 0x40, /* Z (zombie). */ |
33 | support_process_state_parked = 0x80, /* P (parked). */ |
34 | }; |
35 | |
36 | /* Wait for process PID to reach state STATE. It can be a combination of |
37 | multiple possible states ('process_state_running | process_state_sleeping') |
38 | where the function return when any of these state are observed. |
39 | For an invalid state not represented by SUPPORT_PROCESS_STATE, it fallbacks |
40 | to a 2 second sleep. */ |
41 | void support_process_state_wait (pid_t pid, enum support_process_state state); |
42 | |
43 | #endif |
44 | |