X process control

X process control

Post by The Martia » Mon, 16 Apr 2001 11:51:48



Hi

I am trying to write a shell script to only allow a single instance of
PINE to run under X (with windowmaker 0.64).

What I am trying to do is force a existing instance of PINE to the
forground from a script in a different shell session. And this is the
problem, how do I force this process to the forground? I can get the
process ID with no problems.

BTW. I am using bash.

Any suggestions?

Thanks.

David

Sydney, Australia.

 
 
 

X process control

Post by fv » Tue, 17 Apr 2001 05:16:52



>I am trying to write a shell script to only allow a single instance of
>PINE to run under X (with windowmaker 0.64).
>What I am trying to do is force a existing instance of PINE to the
>forground from a script in a different shell session. And this is the
>problem, how do I force this process to the forground? I can get the
>process ID with no problems.

>BTW. I am using bash.

Few things you have to realize:
1) This really isn't that shell dependent.
2) The bash/pine in question doesn't know it's being run from X, it
has nothing to do with X. An xterm (or a work-a-like) gives bash, pine
an interface that works just like a normal terminal.

What you probably want to do, is replace the command with which you
start pine with a script that checks if you're running X (this can be
done by either checking the DISPLAY environment variable or seeing if
TERM is something like 'xterm'* or 'rxvt'. The last option is probably
the neatest, considering what I'm going to suggest). Then if you are
in fact running under X, you use the xsetfocus[1] utility to set the
focus to a window named 'pine'. If this fails (see the exit status of
xsetfocus), set the X-term title to 'pine' (check the Bash-prompt howto
for how to do this). If xsetfocus doesn't fail, the focus is now on
the pine, and you can exit the shell script.

[1] Xsetfocus is a small util I've written (http://www.var.cx/utils/xsetfocus.c)
(I still can't believe there's nothing like this that comes with XFree,
I've probably just missed it. But for the time being, this works).

--
Frank v Waveren                                      Fingerprint: 0EDB 8787



 
 
 

X process control

Post by The Martia » Tue, 17 Apr 2001 11:42:27


Thanks for that your, xsetfocus utils was exactly what I was looking for.

Only snag I cannot get to that server, just times out connecting to
www.var.cx will try again later.

David

Sydney, Australia.



>>I am trying to write a shell script to only allow a single instance of
>>PINE to run under X (with windowmaker 0.64).

>>What I am trying to do is force a existing instance of PINE to the
>>forground from a script in a different shell session. And this is the
>>problem, how do I force this process to the forground? I can get the
>>process ID with no problems.

>>BTW. I am using bash.

> Few things you have to realize:
> 1) This really isn't that shell dependent. 2) The bash/pine in question
> doesn't know it's being run from X, it has nothing to do with X. An
> xterm (or a work-a-like) gives bash, pine an interface that works just
> like a normal terminal.

> What you probably want to do, is replace the command with which you
> start pine with a script that checks if you're running X (this can be
> done by either checking the DISPLAY environment variable or seeing if
> TERM is something like 'xterm'* or 'rxvt'. The last option is probably
> the neatest, considering what I'm going to suggest). Then if you are in
> fact running under X, you use the xsetfocus[1] utility to set the focus
> to a window named 'pine'. If this fails (see the exit status of
> xsetfocus), set the X-term title to 'pine' (check the Bash-prompt howto
> for how to do this). If xsetfocus doesn't fail, the focus is now on the
> pine, and you can exit the shell script.

> [1] Xsetfocus is a small util I've written
> (http://www.var.cx/utils/xsetfocus.c) (I still can't believe there's
> nothing like this that comes with XFree, I've probably just missed it.
> But for the time being, this works).

 
 
 

X process control

Post by fv » Tue, 17 Apr 2001 14:05:55



>Only snag I cannot get to that server, just times out connecting to
>www.var.cx will try again later.

Yup, oops, sorry bout that. You caught me in the middel of a hardware
upgrade... Everything should be running smoothly now..

--
Frank v Waveren                                      Fingerprint: 0EDB 8787


 
 
 

1. Getting process information/Controlling process resource usage

Hi,

        I'm writing a process monitor on Linux. I've 2 questions:

1. How to detect if a process has crashed? Say, if a process hangs, will
   it consume any more CPU time?

2. Is it possible to control the resource limits of a process A by, say,
   process B (run as root)? It seems that the system calls setrlimit,
   ulimit, etc do not take pid as an argument.

        Thanks!

-David

2. Keyboard PB

3. Starting a process without a controlling terminal

4. Win NT4.0 (Sp5) PDC an Samba 2.0.7 (SuSe7.0) as Client

5. Process control in Sys. 5.2

6. Basic Linux ISDN/Ethernet config Qs

7. Controlling Processes

8. Several Questions

9. Controlling forked processes stdin/stdout

10. To Eric P.McCoy::Question on process control again.

11. Monitoring RS-232 modem control signals from a user process ?

12. Background process passwd control

13. Shell disconnection > regaining control of running process