linux: getting umask of an already running process?

后端 未结 5 842
广开言路
广开言路 2021-02-01 17:04

How can I check the umask of a program which is currently running?

[update: another process, not the current process.]

5条回答
  •  鱼传尺愫
    2021-02-01 17:41

    You can attach gdb to a running process and then call umask in the debugger:

    (gdb) call umask(0)
    [Switching to Thread -1217489200 (LWP 11037)]
    $1 = 18
    (gdb) call umask(18)
    $2 = 0
    (gdb) 
    

    (note: 18 = O22)

    This suggests that there may be a really ugly way to get the umask using ptrace.

提交回复
热议问题