Process

程序在使用者下停止但在 root 下執行

  • December 31, 2014

我正在R普通使用者下執行作業,john並且root. 有趣的是,該程序在johnuser 下停止,但在root. 使用strace我發現john執行時R,該程序為其子程序停止。我猜linux不會讓子程序繼續,而父(主程序)會無限停滯。普通linux使用者可以做的fork/clone的數量有什麼限制嗎?知道為什麼會這樣嗎?

無論如何,在這篇文章中,我已經描述了我的問題起點。

更多資訊

使用者的最後幾行(strace程序john停止的地方):

lseek(255, -82, SEEK_CUR)               = 1746
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fa12fd4f9d0) = 13302
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGINT, {0x43d060, [], SA_RESTORER, 0x311b432900}, {0x452250, [], SA_RESTORER, 0x311b432900}, 8) = 0
wait4(-1,  <unfinished ...>

stracefor 的最後幾行root(程序完全執行的地方):

lseek(255, -82, SEEK_CUR)               = 1746
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f81d8e239d0) = 13244
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigaction(SIGINT, {0x43d060, [], SA_RESTORER, 0x311b432900}, {0x452250, [], SA_RESTORER, 0x311b432900}, 8) = 0
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 1}], 0, NULL) = 13244
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
--- SIGCHLD (Child exited) @ 0 (0) ---
wait4(-1, 0x7fff54a591dc, WNOHANG, NULL) = -1 ECHILD (No child processes)
rt_sigreturn(0xffffffffffffffff)        = 0
rt_sigaction(SIGINT, {0x452250, [], SA_RESTORER, 0x311b432900}, {0x43d060, [], SA_RESTORER, 0x311b432900}, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0
read(255, "\n### Local Variables: ***\n### mo"..., 1828) = 82
rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0
read(255, "", 1828)                     = 0
exit_group(1) 

用於strace -f R跟踪 R及其所有子程序。這應該顯示子程序掛起的確切點。

一些額外的可能檢查點:

作為 root ( su - root) 和使用者 john,比較以下輸出:

ulimit -a  #will show all the "limits" set for that user. You may reach one of them?
set ; env  #maybe john & root don't have same PATH or some other thing changes (LD_LIBRARY_PATH? or another?)
grep $(whoami) /etc/passwd /etc/group  #see if john maybe needs to be in some group?

引用自:https://unix.stackexchange.com/questions/59325