diff options
Diffstat (limited to 'src/shared/util.c')
-rw-r--r-- | src/shared/util.c | 28 |
1 files changed, 5 insertions, 23 deletions
diff --git a/src/shared/util.c b/src/shared/util.c index 6c368b61bb..9721779b4b 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -1318,30 +1318,12 @@ void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size, } int proc_cmdline(char **ret) { - int r; - - if (detect_container(NULL) > 0) { - char *buf = NULL, *p; - size_t sz = 0; - - r = read_full_file("/proc/1/cmdline", &buf, &sz); - if (r < 0) - return r; - - for (p = buf; p + 1 < buf + sz; p++) - if (*p == 0) - *p = ' '; - - *p = 0; - *ret = buf; - return 1; - } - - r = read_one_line_file("/proc/cmdline", ret); - if (r < 0) - return r; + assert(ret); - return 1; + if (detect_container(NULL) > 0) + return get_process_cmdline(1, 0, false, ret); + else + return read_one_line_file("/proc/cmdline", ret); } int getpeercred(int fd, struct ucred *ucred) { |