Darius <email@example.com> wrote:
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?
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.
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.
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.
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:
 + Stopped sleep 100000
 - Stoppped (ttyp input) cat
 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.)
Please follow-up to newsgroup, rather than personal email.
QNX Training Services