Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I used Xterm -e command to run six programs in the background in six X terminals in my shell script. When I used PS command, I can see 6 Xterm process running in the background but I can't see the programs. If I used Top command, I can see the programs. Is there a clean way to kill all the x terminals and the programs?

Here is the xterminal command in my script:

xterm -e "script -c \"program\" outputfile" &

Another problem is I try to capture the output of the program to a file, but for some reason I can only capture part of it. If I get rid of the & at the end, I can capture all the output but I can't get control back since the program is running as a server, which means it doesn't end unless I kill the server.

share|improve this question

migrated from Feb 1 '11 at 13:55

This question came from our site for professional and enthusiast programmers.

ps without arguments/options displays only processes connected to the current terminal. Anything you run in a new xterm will have that xterm's pseudotty as its controlling terminal.

You can usually get away with killing the xterms to kill the programs running in them.

share|improve this answer
Thanks for the reply. I did close all the xterms. But top still shows those processing are running. – Anonymous Jan 31 '11 at 19:19

These three links may be of interest:

  1. pgrep and pkill - Solaris specific page
  2. This page on window process management on U&L
  3. The Process Chain at docstore
share|improve this answer

You must log in to answer this question.