LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-07-2003, 12:29 PM   #1
drgowans
LQ Newbie
 
Registered: Sep 2003
Location: Salt Lake City, Utah
Distribution: Red Hat 9
Posts: 22

Rep: Reputation: 15
I want to figure out which display a process is running on


I'm using Redhat 9

I have a program that I wrote to run in HP-UX that will use ps, top, and who to look for a specific process, then pop up a warning message to the user if that process is using too much memory. It is written in python.

who -u prints the display(host) next to all the pts/# entries, but in Redhat 9 it doesn't:

who from Linux (Redhat 9) - note how the display (xt005:0.0, etc) isn't displayed...

image xt005:0 Nov 7 08:22 ? 32555 (xt005)
image pts/0 Nov 7 08:22 00:48 32650 (xt005:0.0)
image pts/1 Nov 7 08:27 02:55 32747
image xt011:0 Nov 7 08:35 ? 670 (xt011)
image pts/2 Nov 7 08:35 02:47 739
image :0 Nov 7 08:35 ? 593
image pts/3 Nov 7 08:35 02:47 776
image pts/4 Nov 7 08:37 . 807

who from HP-UX - note how it shows the host name and display for everything

image console Nov 5 15:25 old 28062 hpcam06
image ttyp1 Nov 7 07:44 old 9165 xt004:1.0
image dtremote Nov 4 22:28 old 3735 hpcam01:0
image dtremote Nov 7 07:44 old 9141 xt004:1
image ttyp2 Nov 5 15:25 old 28079 hpcam06:0.0
image pts/1 Nov 7 07:49 3:36 9231 xt004:1.0
image ttyp3 Nov 4 22:28 old 3752 hpcam01:0.0
image pts/2 Nov 7 08:58 2:27 9662 hpcam01:0.0
image ttyp4 Nov 7 07:49 old 9253 xt014:0.0
image pts/3 Nov 7 11:26 . 12868 lxcam08

How do I link a tty with a display? What other programs would give me the information I need?

Thanks!
 
Old 11-07-2003, 01:25 PM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
ps -f shows the tty
Code:
ps -f
# you could restrict it to a comma-separated user list with -U 
ps -f -U `who -q | tr -s ' ' ','`  /* this returns all users */
 
Old 11-07-2003, 01:26 PM   #3
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
PS:

ps -ef gives you EVERY process, some of which have no tty.
 
Old 11-07-2003, 03:29 PM   #4
drgowans
LQ Newbie
 
Registered: Sep 2003
Location: Salt Lake City, Utah
Distribution: Red Hat 9
Posts: 22

Original Poster
Rep: Reputation: 15
Thanks, but how to link to display?

I use ps -ef to get the tty, but I need to link the tty to the display.

For example, I have a process called 'get' running on pts/3 with process # 455. How do I use this information to find out the display, as in "<hostname>:#.#"?

Many thanks
 
Old 11-10-2003, 11:32 AM   #5
drgowans
LQ Newbie
 
Registered: Sep 2003
Location: Salt Lake City, Utah
Distribution: Red Hat 9
Posts: 22

Original Poster
Rep: Reputation: 15
Since nobody else seems to be able to help...

I understand that there isn't a direct correllation between a tty/pts, etc and a display, but no suggestions from anyone expect one person (and many thanks to that one person)?

Anyhow, for the future, I'll let everyone know how I had to do it.

I created a wrapper script for the graphical process I am attempting to track, which wrote to a log directory the process number and display variable when it launched the script.

The log program can then read the files in that directory, and hence there is a direct link between the process and the display it is running on. It then can use ps/top, etc to gather other information on the process.

So does nobody know of any system commands that will give the display/host of a process? It seems that it would be a fundamental piece of information that the kernel has to manage - why can't it be accessed?

Thanks!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Starting process on display :1 noware Linux - General 8 12-01-2005 06:52 AM
How can I figure out what processes I need to have running and which ones I dont? Kramer Linux - General 9 08-06-2004 10:51 PM
Change the display of a running process? ejkeebler Linux - Newbie 3 06-16-2004 08:43 AM
display boot process to LCD.. rohan208 Programming 3 06-07-2004 07:55 PM
Can't figure out DISPLAY and GUI apps from remote console. bkeating Linux - Newbie 1 04-29-2004 02:18 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration