diff options
Diffstat (limited to 'src/lib/common.c')
-rw-r--r-- | src/lib/common.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/lib/common.c b/src/lib/common.c index fc4c167ba..ea0ab781a 100644 --- a/src/lib/common.c +++ b/src/lib/common.c | |||
@@ -260,5 +260,26 @@ int pid_proc_cmdline_x11_xpra_xephyr(const pid_t pid) { | |||
260 | return 0; | 260 | return 0; |
261 | } | 261 | } |
262 | 262 | ||
263 | // return 1 if /proc is mounted hidepid, or if /proc/mouns access is denied | ||
264 | #define BUFLEN 4096 | ||
265 | int pid_hidepid(void) { | ||
266 | FILE *fp = fopen("/proc/mounts", "r"); | ||
267 | if (!fp) | ||
268 | return 1; | ||
269 | |||
270 | char buf[BUFLEN]; | ||
271 | while (fgets(buf, BUFLEN, fp)) { | ||
272 | if (strstr(buf, "proc /proc proc")) { | ||
273 | fclose(fp); | ||
274 | // check hidepid | ||
275 | if (strstr(buf, "hidepid=2") || strstr(buf, "hidepid=1")) | ||
276 | return 1; | ||
277 | return 0; | ||
278 | } | ||
279 | } | ||
280 | |||
281 | return 0; | ||
282 | } | ||
283 | |||
263 | 284 | ||
264 | 285 | ||