[oclug] how to get a process's tty
Roger Messier
en916 at ncf.ca
Fri Apr 9 12:25:04 EDT 2004
On Fri, 09 Apr 2004 06:17:15 -0400 "Francis J. A. Pinteric"
<linuxdoctor at linuxdoctor.biz> wrote:
> >
> > Thanks Francis, but since my program runs with my uid, that doesn't
> > work for processes owned by users other than me. The program
> > doesn't have read permissions for processes owned by other users.
> >
>
> Hmm, you're right. I wonder how ps does it? You can always track
> down the source code for ps and see. Then again, unless you can't use
> shell language, you can always try this:
>
> [fja at localhost proc]$ ps | awk -- '{ print $1 " " $2}'
> PID TTY
> 2589 pts/3
> 21179 pts/3
> 21180 pts/3
>
I can't use any shell utilities. It has to be written in C. I've been
reading the source code for ps and top, but I'm having a hard time
understanding it, and I'm running out of time. So I guess I'll just
stick with my current method.
Thanks anyways.
--
Roger Messier
Email: en916 at ncf.ca
Jabber ID: rogerm at nureality.ca
PGP KeyID (pgp.mit.edu): 1827131D
Blessed are they who can laugh at themselves,
for they shall never cease to be amused.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://tux.oclug.on.ca/pipermail/oclug/attachments/20040409/8260f1c4/attachment.bin
More information about the OCLUG
mailing list