diff options
| author | Michael Biebl <biebl@debian.org> | 2023-10-04 11:46:00 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2023-10-04 11:46:00 +0200 |
| commit | 2f3cc04ff8a04278f01e4636f48a98f8f2e96b21 (patch) | |
| tree | 4fc86e4ed1429cc563941a06b05b3a03b991b368 /src/core/main-utils.c | |
| parent | 491a3eba00b23412605366b5e0c0b1e35923b9c6 (diff) | |
| parent | d4d8b2b91f7ba000d97a8b2aab48c85000c11314 (diff) | |
Update upstream source from tag 'upstream/1.44.2'
Update to upstream version '1.44.2' with Debian dir 40e7c53062e3f5993a56cbed3a58b49f1c78441a
Diffstat (limited to 'src/core/main-utils.c')
| -rw-r--r-- | src/core/main-utils.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/core/main-utils.c b/src/core/main-utils.c index c6fa05c0..9360d688 100644 --- a/src/core/main-utils.c +++ b/src/core/main-utils.c @@ -158,7 +158,8 @@ nm_main_utils_ensure_not_running_pidfile(const char *pidfile) gs_free char *contents = NULL; gs_free char *proc_cmdline = NULL; gsize len = 0; - long pid; + pid_t pid; + gint64 pid64; const char *process_name; const char *prgname = g_get_prgname(); @@ -173,12 +174,13 @@ nm_main_utils_ensure_not_running_pidfile(const char *pidfile) return; errno = 0; - pid = strtol(contents, NULL, 10); - if (pid <= 0 || pid > 65536 || errno) + pid64 = _nm_utils_ascii_str_to_int64(contents, 10, 0, G_MAXINT64, -1); + pid = (pid_t) pid64; + if (pid <= 0 || (gint64) pid != pid64) return; nm_clear_g_free(&contents); - proc_cmdline = g_strdup_printf("/proc/%ld/cmdline", pid); + proc_cmdline = g_strdup_printf("/proc/%" G_GINT64_FORMAT "/cmdline", (gint64) pid); if (!g_file_get_contents(proc_cmdline, &contents, &len, NULL)) return; @@ -190,7 +192,10 @@ nm_main_utils_ensure_not_running_pidfile(const char *pidfile) if (strcmp(process_name, prgname) == 0) { /* Check that the process exists */ if (kill(pid, 0) == 0) { - fprintf(stderr, _("%s is already running (pid %ld)\n"), prgname, pid); + fprintf(stderr, + _("%s is already running (pid %" G_GINT64_FORMAT ")\n"), + prgname, + (gint64) pid); exit(1); } } |