Darius <alpha_byte@safe-mail.net> wrote:
Hello,
Suppose I have two programs. I run one from sh. How to return to sh and run
another if first program runs for a long time (suppose until I press some
combination of keys). As an example imagine windows. I run app and I can
switch to windows with alt+tab. How to do similar thing in QNX?
Thanks
Other responses haven’t covered another option – job control.
In any particular “sh” session, only one program at a time can have
access to input from the terminal – it is called the “foreground”
process. Other processes can be running on the sh (really terminal
of some type), and be able to do output to it, but not get input.
They are called “background” processes.
When you run a program, by default it is in the foreground.
$ program
If you run a program with an ampersand ‘&’ character after it, it is
in the background.
$ program &
If you want a list of background processes, type jobs.
$ jobs
If a program is running in the foreground (you forgot the &, or you
made a background process do so), you can make stop it with ctrl-Z.
It will be shown in the jobs list as “Stopped”.
If you want it to run in the background, type bg.
$ bg
Now it will be running. If it tries to get terminal input, it will stop,
and jobs will show it as “Stopped (tty input)”.
Sample jobs output:
[2] + Stopped sleep 100000
[3] - Stoppped (ttyp input) cat
[1] Running sleep 50000
The ones labelled as “Running” are background processes.
If you want to bring one of the stopped or background processes to
the foreground (for instance, if you want to provide input to the cat
program) you can use the fg command, with %job-number.
$ fg %3
Now, any typed input will go to cat, until you type ctrl-Z again.
Both fg and bg, if not given a job number will operate on the process
listed with a plus ‘+’ character in the jobs listing.
The previous set of things is quite helpful if you only have a serial
connection to a target, and wish to do several things. (With telnet, you
can often just create multiple sessions, with an actual console, you
might have multiple virtual consoles, or if running Photon, multiple
command windows (pterms) open.)
-David
Please follow-up to newsgroup, rather than personal email.
David Gibbs
QNX Training Services
dagibbs@qnx.com