1 /*
2 Copyright 2021 Northern.tech AS
3
4 This file is part of CFEngine 3 - written and maintained by Northern.tech AS.
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; version 3.
9
10 This program 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
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
18
19 To the extent this program is licensed as part of the Enterprise
20 versions of CFEngine, the applicable Commercial Open Source License
21 (COSL) may apply to this file if you as a licensee so wish it. See
22 included file COSL.txt.
23 */
24
25 #include <cf3.defs.h>
26 #include <process_lib.h>
27 #include <process_unix_priv.h>
28
GetProcessStartTime(ARG_UNUSED pid_t pid)29 time_t GetProcessStartTime(ARG_UNUSED pid_t pid)
30 {
31 Log(LOG_LEVEL_VERBOSE,
32 "No platform-specific code for obtaining process start time. - "
33 "Falling back to no PID double-checking on kill()");
34
35 return PROCESS_START_TIME_UNKNOWN;
36 }
37
GetProcessState(pid_t pid)38 ProcessState GetProcessState(pid_t pid)
39 {
40 Log(LOG_LEVEL_DEBUG,
41 "No platform-specific code for obtaining process state. - "
42 "Falling back to no PID double-checking on kill()");
43
44 if (kill(pid, 0) < 0 && errno == ESRCH)
45 {
46 return PROCESS_STATE_DOES_NOT_EXIST;
47 }
48
49 /* It might be RUNNING, STOPPED or ZOMBIE, but we can't tell the
50 * difference without platform specific code. */
51 return PROCESS_STATE_RUNNING;
52 }
53