X-Git-Url: http://git.sven.stormbind.net/?p=sven%2Fjattach.git;a=blobdiff_plain;f=src%2Fposix%2Fpsutil.c;fp=src%2Fposix%2Fpsutil.c;h=d0287f598e2955c4c418be2a1e3cc24b735d5634;hp=9beea88f54b095c09db0b33a34985a12d9c4b0d5;hb=443b80898c49b466100dffc328ea8905887af2a1;hpb=98ce3928a99273b631c525a81df022e6f8ec46a7 diff --git a/src/posix/psutil.c b/src/posix/psutil.c index 9beea88..d0287f5 100644 --- a/src/posix/psutil.c +++ b/src/posix/psutil.c @@ -1,5 +1,5 @@ /* - * Copyright 2021 Andrei Pangin + * Copyright jattach authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -93,15 +93,14 @@ static int alt_lookup_nspid(int pid) { // Check if /proc//sched points back to snprintf(path, sizeof(path), "/proc/%d/root/proc/%s/sched", pid, entry->d_name); if (sched_get_host_pid(path) == pid) { - closedir(dir); - return atoi(entry->d_name); + pid = atoi(entry->d_name); + break; } } } closedir(dir); } - // Could not find container pid; return host pid as the last resort return pid; }