ls_rtask() function

You can use of ls_rexecv() for remote execution. You can also use ls_rtask() for remote execution. ls_rtask()and ls_rexecv() differ in how the server host behaves.

ls_rexecv() is useful when the server host does not need to do anything but wait for the remote task to finish. After initiating the remote task, ls_rexecv() replaces the current program with the Network I/O Server (NIOS) by calling execv(). The NIOS then handles the rest of the work on the server host: delivering input/output between local terminal and remote task and exiting with the same status as the remote task. ls_rexecv() is considered to be the remote execution version of the UNIX execv() system call.

ls_rtask()

ls_rtask() provides more flexibility if the server host has to do other things after the remote task is initiated. For example, the application may want to start more than one task on several hosts. Unlike ls_rexecv(), ls_rtask() returns immediately after the remote task is started. The syntax of ls_rtask() is:

int ls_rtask(host, argv, options)

The parameters are:

char *host;                Name of the remote host to start task on
char **argv;               Program name and arguments
int  options;               Remote execution options

options parameter

The options parameter is similar to that of the ls_rexecv() function. ls_rtask() returns the task ID of the remote task which is used by the application to differentiate multiple outstanding remote tasks. When a remote task finishes, the status of the remote task is sent back to the NIOS running on the local host, which then notifies the application by issuing a SIGUSR1 signal. The application can then call ls_rwait() to collect the status of the remote task. The ls_rwait() behaves in much the same way as the wait(2) system call. Consider ls_rtask() as a combination of remote fork() and execv().

Tip:

Applications calling ls_rtask() must set up a signal handler for the SIGUSR1 signal, or the application could be killed by SIGUSR1.

You need to be careful if your application handles SIGTSTP, SIGTTIN, or SIGTTOU. If handlers for these signals are SIG_DFL, the ls_rtask() function automatically installs a handler for them to properly coordinate with the NIOS when these signals are received. If you intend to handle these signals by yourself instead of using the default set by LSLIB, you need to use the low level LSLIB function ls_stoprex() before the end of your signal handler.