Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

on

Execute a command on another node or tty (QNX Neutrino)

Syntax:

on [-C cpunum] [-d] [-h]  [-n|f nodename] [-P]
   [-p priority[policy]] [-R runmask] [-s]
   [-t tty] [-u user | -l user_name] [-W nsec]
   [-w device] [-Xsched_command] [command [args]]

Runs on:

Neutrino

Options:

-C cpunum
(QNX Neutrino Core OS 6.3.2 or later) Set the CPU affinity to cpunum, where the first CPU is 0. You can use this option multiple times. For more information, see Setting the runmask,” below.
-d
Detach command from its parent (i.e. sever the parent/child relationship). This is useful for remotely created processes that never exit and that the shell therefore doesn't need to wait for. Unless this option is specified, a network connection is created connecting the parent to the child.
-f nodename
Spawn from the remote node using the remote node's / as prefix root.
-h
Start command in a HELD state. This option is useful for starting up programs with the intention of debugging them. You can also start up several commands in the HELD state, then send them all a signal to start — they'll all start at almost the exact same time, since their load times will have been eliminated.
-l user_name
Login as the given user. This option is similar to the -u option, but also sets the LOGNAME, HOME, and SHELL environment variables, sets the umask to 022, and changes to the directory specified for the user in the password database.
-n nodename
Execute command on remote nodename.
-P
(QNX Neutrino 6.4.0 or later) Spawn the process, setting the SPAWN_PADDR64_SAFE flag to indicate that the process is known to operate safely with 64-bit addressing or doesn't care about the physical memory location.
-p priority[policy]
Execute the command at the specified priority, optionally changing the scheduling policy.

Priorities are in the range from 0 through 255. Priority 0 is used for the idle thread; by default, priorities of 64 and greater are privileged, so only processes with an effective user ID of 0 (i.e. root) can use them. Non-root (and root) processes can use priorities from 1 through 63.

You can change the range of privileged priorities with the -P option for procnto.

The scheduling policy must be one of:

If you don't specify a command, the change applies to the parent process.

-R runmask
(QNX Neutrino Core OS 6.3.2 or later) Set the CPU affinity to runmask. You can use this option multiple times to specify masks that are more than 32 bits long. For more information, see Setting the runmask,” below.
-s
Spawn the command in a new process group.
-t tty
Open the specified terminal name as file descriptors 0, 1, and 2 for command. The command is run in a new session with tty as its controlling terminal. If tty doesn't contain a slash (/), /dev/ is added to the beginning.
-u uid[:gid[,gid,…]]
-u user_name
Run as the user specified by the numeric uid, in the specified group(s), or as the given user_name.
-W nsec
The number of seconds to wait for the device specified in the following -w option. The default is forever.
-w device
Wait for a stat() on the given device to succeed before continuing. If device doesn't contain a slash (/), /dev/ is added to the beginning.

Note: You can repeat the -w and -W options on the command line. They're processed in the order given, before any other options.

-Xsched_cmd
Launch using the specified command for an external scheduler. The possible commands include:

This option was added in the QNX Neutrino Core OS 6.3.2.

command [args]
The command to be executed, and any arguments to be passed to it.

Description:

The on utility extends the process creation abilities of the shell (sh). You can start a process on a remote node, on a different controlling terminal, in a HELD state for debugging or later synchronized starting.

If the -d option isn't specified, a network connection is created as a local agent for the remote child process. When the child terminates, the parent must do a wait() on the created connection to reap the zombie process entry for the child. If the -d option is specified, the command is detached from its parent. The parent isn't able to do a wait() for the child, nor is it able to control it via signals.

By default, the command is run in the current session. The -t option starts a new session, which means the command won't receive a SIGHUP if the current session leader terminates.


Caution: The on -t command becomes the new session leader on the tty specified, i.e. it receives SIGHUP generated by hangups on that tty. Any processes originally running on that tty don't get SIGHUP, and this condition persists even when the process started by on has terminated. For this reason, specify only ttys that aren't currently in use.

Setting the runmask

On a multicore system, you can use a runmask to specify which processors a thread or process can run on. The default is all 1s (i.e. all CPUs).


Note: The runmask is useful only on multiprocessor systems.

You can use on to set the runmask and inherit mask for a new process; to change the masks for threads that are already running, use slay. Both commands interpret the -C and -R options in the same way.

You can use more than one -R option to specify a runmask that's more than 32 bits long. The first -R option specifies bits 0 through 31, the second specifies bits 32 through 63, and so on.

If you use both the -C and -R options or multiple instances of them, the resultant mask is the bitwise ORing of all -C and -R options. For example, on -R 0x1 is equivalent to on -C0, and on -R 0x1 -C3 is equivalent to on -C0 -C3. The on command sets the process's runmask and inherit mask to the same value.

For more information about runmasks, see the Multicore Processing chapter of the System Architecture guide, and the Developing Multicore Systems chapter of the Multicore Processing User's Guide.

Examples:

Run login on console 2:

on -t con2 login

Run who on node 3:

on -n 3 who

Run sort as an orphan on the node named peterv:

on -d -n peterv sort file.dat

Run who on node 7 with a new session, its standard I/O connected to console 1 on node 3:

on -t //3/dev/con1 -n7 who

Exit status:

The on utility exits with the exit status of command.

See also:

nice, sh, slay

stat() in the Library Reference

Multicore Processing chapter of the System Architecture guide, the Multicore Processing User's Guide

Adaptive Partitioning User's Guide