Tuesday, August 29, 2006

 

Grabbing the umask of a running process via MDB

Wow, this was actually easier than I thought. I set out to see if I could figure out the umask of a process via MDB. I tried to figure out other ways to get this information, but I didn't come across anything. The umask isn't an environment variable, so something like "pargs -e" won't tell you anything.

So the umask of a process is just a field in the data structure that defines a process, proc_t. Specifically, it's the u_cmask field of that structure, so you can just do something like this (output slightly modified for formatting):

server# mdb -k
>  ::pgrep sshd
S    PID PPID PGID  SID UID             ADDR NAME
R   6311    1 6311 6311   0 ffffffff90064d48 sshd
> ffffffff90064d48::print -t proc_t ! grep u_cmask
        mode_t u_cmask = 0x12
>
And, of course, there are slightly different ways of doing the same thing. For example:

> 0t6311::pid2proc | ::print -t proc_t p_user.u_cmask
mode_t p_user.u_cmask = 0x12
>
So here we have a umask of 022 (note that it's printed in hex above, not octal.)

(I seem to remember having Googled this sometime late last week and coming up with nothing. My search history doesn't bear witness to this, though, and a quick Google of "umask running process solaris" points to this thread.)

Comments:
Thanks for this cool method of finding umask of a running process.
 
Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?