process-util: shortcut get_process_state() for our own process
This commit is contained in:
parent
cde93ba2a5
commit
5c7b99745a
|
@ -52,13 +52,17 @@
|
|||
#define COMM_MAX_LEN 128
|
||||
|
||||
static int get_process_state(pid_t pid) {
|
||||
_cleanup_free_ char *line = NULL;
|
||||
const char *p;
|
||||
char state;
|
||||
int r;
|
||||
_cleanup_free_ char *line = NULL;
|
||||
|
||||
assert(pid >= 0);
|
||||
|
||||
/* Shortcut: if we are enquired about our own state, we are obviously running */
|
||||
if (pid == 0 || pid == getpid_cached())
|
||||
return (unsigned char) 'R';
|
||||
|
||||
p = procfs_file_alloca(pid, "stat");
|
||||
|
||||
r = read_one_line_file(p, &line);
|
||||
|
|
Loading…
Reference in New Issue