Get process status from procfs
[platform/core/connectivity/stc-manager.git] / src / helper / helper-procfs.h
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #ifndef __HELPER_PROCFS_H__
19 #define __HELPER_PROCFS_H__
20
21 #include <stdio.h>
22
23 #define PROC_BUF_MAX 64
24
25 /**
26  * @desc get command line from /proc/{pid}/cmdline
27  * @return negative value if error
28  */
29 int proc_get_cmdline(pid_t pid, char *cmdline);
30
31 /**
32  * @desc find pid with /proc/{pid}/cmdline
33  * it returns first entry when many pids have same cmdline
34  * @return negative value if error
35  */
36 pid_t find_pid_from_cmdline(char *cmdline);
37
38 /**
39  * @desc get smack subject label from /proc/{pid}/attr/current
40  * this label can indicate package name about child processes
41  * @return negative value if error or pid doesn't exist
42  */
43 int proc_get_label(pid_t pid, char *label);
44
45 /**
46  * @desc get command line from /proc/{pid}/cmdline without any truncation
47  * @return negative value if error
48  */
49 int proc_get_raw_cmdline(pid_t pid, char *buf, int len);
50
51 /**
52  * @desc get symblolic link about /proc/{pid}/exe
53  * @return negative value if error
54  */
55 int proc_get_exepath(pid_t pid, char *buf, int len);
56
57 /**
58  * @desc get status from /proc/{pid}/status
59  * @return negative value if error
60  */
61 int proc_get_status(pid_t pid, char status[][PROC_BUF_MAX]);
62
63 #endif /*__HELPER_PROCFS_H__*/