Free Downloads, Community Forum,
FAQs and Developer Resources


Make /Tools Your Home | Link to us

Today's posts | Posts since last visit | Most Active Topics

All Forums Register Login Search Subscriptions My Profile Inbox
Tool Warehouse FAQs Resources Help Member List Address Book Logout

Problems with psinfo_t and tty

 
Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [SFU / Interix / SUA Technology] >> Interix Advanced Forum >> Problems with psinfo_t and tty Page: [1]
Login
Message << Older Topic   Newer Topic >>
Problems with psinfo_t and tty - Apr. 6, '06, 11:07:21 AM   
BBR

 

Posts: 4
Joined: Jan. 5, '06,
Status: offline
I have following problem:

Having the name of the TTY (/dev/ttyp0 for example) i need to get all processes attached to it. My steps:

1. Get TTY's descriptor:
struct stat st;
...
if (stat(ttyName, &st) >= 0 && (st.st_mode & S_IFMT) == S_IFCHR))
tty = st.st_rdev;

2. Check processes:
dirfp = opendir("/proc");
...
sprintf(name, "/proc/%s/psinfo", dp->d_name);
fd = open(name, O_RDONLY);
...
static psinfo_t pi;
read(fd, &pi, sizeof(pi));
if (pi.pr_ttydev == tty) ...

And this isn't work.
For example, stat /dev/ttyp0 shows:
...
dev: 1073741891
...

cat /proc/1157/stat
...
tty ttyp0
...

But in my code pi.pr_ttydev for PID 1157 is 96. Why ?

_____________________________

Boris B. Rudakov
Post #: 1
RE: Problems with psinfo_t and tty - Apr. 6, '06, 2:31:14 PM   
Rodney

 

Posts: 3714
Joined: Jul. 9, '02,
From: /Tools lab
Status: offline
Because it's terminal 96 of all terminals (glass + serial + slave pty).

(in reply to BBR)
Post #: 2
RE: Problems with psinfo_t and tty - Apr. 6, '06, 3:08:01 PM   
BBR

 

Posts: 4
Joined: Jan. 5, '06,
Status: offline
quote:

ORIGINAL: Rodney

Because it's terminal 96 of all terminals (glass + serial + slave pty).


But why ?

Code above works fine on most unixes (look 'skill' tool code for example).

How ps gets terminal names ?

_____________________________

Boris B. Rudakov

(in reply to Rodney)
Post #: 3
RE: Problems with psinfo_t and tty - Apr. 6, '06, 3:18:28 PM   
Rodney

 

Posts: 3714
Joined: Jul. 9, '02,
From: /Tools lab
Status: offline
From the /proc/<pid>/stat file which is all in text.
One of the lines starts "tty" and is followed by the tty's name
(without the leading "/dev/").

(in reply to BBR)
Post #: 4
Page:   [1]
All Forums >> [SFU / Interix / SUA Technology] >> Interix Advanced Forum >> Problems with psinfo_t and tty Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Search All Forums -

Advanced search


SPONSORS



Forum Software © ASPPlayground.NET Advanced Edition 2.5 ANSI

0.031