multithreaded apps

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

Best regards,
Darius

“Darius” <alpha_byte@SAFe-mail.net> wrote in message
news:cfdon3$2np$2@inn.qnx.com

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?

You need to open a new shell (if what you want is the equivalent of
alt+tab).

If you are running in text mode type CTRL-ATL-X to switch other console ( X
is a number from 0 to 9 )
If you are running in photon just open a new pterm. If you are running a
telnet session, open another session.


Thanks

Best regards,
Darius

Mario Charest wrote:

“Darius” <> alpha_byte@SAFe-mail.net> > wrote in message
news:cfdon3$2np$> 2@inn.qnx.com> …

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?


You need to open a new shell (if what you want is the equivalent of
alt+tab).

If you are running in text mode type CTRL-ATL-X to switch other console ( X
is a number from 0 to 9 )
If you are running in photon just open a new pterm. If you are running a
telnet session, open another session.

or If you only have one shell in text mode only, you can use the ‘&’
after your program, this runs your program and returns to the shell.

Example:

program1 &

program2 &

The output will get a little confusing though if your programs output
information.

Two separate consoles/pterms is still the best way. :wink:


Thanks

Best regards,
Darius

\

Hello,

The output will get a little confusing though if your programs output
information.

Two separate consoles/pterms is still the best way. > :wink:

So as I can understand one program need one console? If I would start
another sh, so the first will be running in memory if I would use “sin ver”.
So if my program outputs something to sonsole I need one for every app?

Best regards,
Darius

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

“Darius” <alpha_byte@SAFe-mail.net> wrote in message
news:cfdvjf$7j0$2@inn.qnx.com

Hello,

The output will get a little confusing though if your programs output
information.

Two separate consoles/pterms is still the best way. > :wink:

So as I can understand one program need one console?

Yes an no, program doesn’t need it, it mostly to make it easy for normal
human :wink:

If I would start
another sh, so the first will be running in memory if I would use “sin
ver”.

So if my program outputs something to sonsole I need one for every app?

Yes unless you don’t mind having each program output in the same console,
which in most cases results in total chaos :wink:

Best regards,
Darius

Hello,

Other responses haven’t covered another option – job control.

Thank you for your answers. I have one more question. If my program runs in
background is it with smaller priority or it is the same as running in
foreground?

Darius

Darius <alpha_byte@safe-mail.net> wrote:

Hello,

Other responses haven’t covered another option – job control.

Thank you for your answers. I have one more question. If my program runs in
background is it with smaller priority or it is the same as running in
foreground?

Background/foreground here doesn’t change priority.

To change priority, you’d have to look at the Unix nice (change
priority on launch) or renice (change priority of running process).

Or, the QNX utility slay can also be used to set the priority of
a running process.

Unfortunately, these are not part of the shell’s job control – so
they don’t take job numbers, but instead process ids (or, with
slay, a process name – the command that was run.)

-David

Please follow-up to newsgroup, rather than personal email.
David Gibbs
QNX Training Services
dagibbs@qnx.com

$ program

it seems that sh does not recognize $ character

Darius

Darius <alpha_byte@safe-mail.net> wrote:

$ program

it seems that sh does not recognize $ character

The $ is the (default) command-line prompt for non-root users (for the
root user, the default prompt is #). Just type:

program


Steve Reid stever@qnx.com
TechPubs (Technical Publications)
QNX Software Systems

Darius <alpha_byte@safe-mail.net> wrote:

$ program

it seems that sh does not recognize $ character

Sorry, I was trying to represent the shell prompt – not type that, but
when you see the prompt (default $ for non-root users, default # for
root users), you should type program.

-David

Please follow-up to newsgroup, rather than personal email.
David Gibbs
QNX Training Services
dagibbs@qnx.com