using sudo emerge something, sudo eats up >90% of the CPU time. htop s revealed that sudo continuosly calls waitpid(somepid, someaddress,WNOHANG|WSTOPPED) = 0. There is typo in exec.c which probably caused this misbehaviour: 257 do { 258 #ifdef sudo_waitpid 259 pid = sudo_waitpid(child, &status, WUNTRACED|WNOHANG); 260 #else 261 pid = wait(&status); 262 #endif 263 if (pid == child) { 264 if (!log_io) { 265 if (WIFSTOPPED(status)) { 266 /* Child may not have privs to suspend us itself. */ 267 kill(getpid(), WSTOPSIG(status)); 268 } else { 269 /* Child has exited, we are done. */ 270 cstat->type = CMD_WSTATUS; 271 cstat->val = status; 272 return 0; 273 } 274 } 275 /* Else we get ECONNRESET on sv[0] if child dies. */ 276 } 277 } while (pid != -1 || errno == EINTR); The last line should probably read: 277 } while (pid == -1 || errno == EINTR);
Sorry, there are two logical errors. Line 277 should read: 277 } while (pid == -1 && errno == EINTR);
Would you mind reporting this upstream?
(In reply to comment #2) > Would you mind reporting this upstream? I checked upstream in the meantime. Apparently, they rewrote much of exec.c, and the do - loop condition appears to be correct now. But if you think that reporting it still makes sense, I'll do.
app-admin/sudo-1.7.2_p7 and app-admin/sudo-1.7.3 appear also to be affected by this, one way or another. Look into sudo_edit.c instead of exec.c or do a "grep EINTR *.c". There is also a security issue pending (BUG #322517) for app-<=admin/sudo-1.7.2_p7.
1.7.4_p2 was released today so I'll bump and remove 1.7.4. The security issue is just waiting GLSA; I wouldn't count this as an enormous problem to ask stable of the new version right away, but I'll track this faster.