/* verify cap_last_cap() against /proc/sys/kernel/cap_last_cap */ static void test_last_cap_file(void) { _cleanup_free_ char *content = NULL; unsigned long val = 0; int r; r = read_one_line_file("/proc/sys/kernel/cap_last_cap", &content); assert_se(r >= 0); r = safe_atolu(content, &val); assert_se(r >= 0); assert_se(val != 0); assert_se(val == cap_last_cap()); }
int parse_pid(const char *s, pid_t* ret_pid) { unsigned long ul = 0; pid_t pid; int r; assert(s); assert(ret_pid); r = safe_atolu(s, &ul); if (r < 0) return r; pid = (pid_t) ul; if ((unsigned long) pid != ul) return -ERANGE; if (pid <= 0) return -ERANGE; *ret_pid = pid; return 0; }