getpid/kill question
From: Joe Cipale (joec_at_aracnet.com)
Date: 05/09/04
- Next message: Kasper Dupont: "Re: getpid/kill question"
- Previous message: Norm Dresner: "Re: Why linux is so stupid with hardware drivers?"
- Next in thread: Kasper Dupont: "Re: getpid/kill question"
- Reply: Kasper Dupont: "Re: getpid/kill question"
- Reply: Michal Wojciechowski: "Re: getpid/kill question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 09 May 2004 11:11:34 -0700
I have a application that spawns an xterm window using system(). I only
want the spawned window to be displayed for as long as the user is in a
certain 'location' of the application. Once they exit, then the spawned
window is to be terminated.
This lead me to use the following code snippet:
pid_t pid;
getpid = system("xterm \"Display\" -geom 80x40 &");
cout << "Var check: getpid() = " << getpid << endl;
system("kill -9 getpid");
When I exececute the system call to create the xterm and display the pid
value, the value is '0'. I then go to another window and perform:
%ps -aux | grep xterm | grep Display
and I get a pid value that != '0'.
I would like to do this as elegantly as possible, without having to
resort to awk/sed within my code. I have the book "Advanced Programming
in the Unix Environment" by Richard Stevens, but I have not quite found
the answer to my task.
Would I be better off using something other than system() that will
generate a 'true' pid? fork() or exec*() perhaps?
TIA,
Joe
-- #----------------------------------------------------------# # "Don't fear the penguin!" # #----------------------------------------------------------# # Registered Linux user: #309247 http://counter.li.org # #----------------------------------------------------------#
- Next message: Kasper Dupont: "Re: getpid/kill question"
- Previous message: Norm Dresner: "Re: Why linux is so stupid with hardware drivers?"
- Next in thread: Kasper Dupont: "Re: getpid/kill question"
- Reply: Kasper Dupont: "Re: getpid/kill question"
- Reply: Michal Wojciechowski: "Re: getpid/kill question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|