---
name: "drmaa_wtermsig"
section: "3"
platform: "linux"
package: "gridengine-drmaa-dev"
version: "6.2u5-7.1"
release: "Debian 7 (Wheezy)"
platforms: ["linux"]
url: "https://new.carta.tech/drmaa_wait"
---

# drmaa\_wtermsig(3)

Waiting for jobs to finish

Part of [drmaa\_wait(3)](/drmaa_wait/3.md).

## NAME

drmaa\_synchronize, drmaa\_wait, drmaa\_wifexited, drmaa\_wexitstatus, drmaa\_wifsignaled, drmaa\_wtermsig, drmaa\_wcoredump, drmaa\_wifaborted - Waiting for jobs to finish

## SYNOPSIS

**#include "drmaa.h"**

```
int drmaa_synchronize(
const char *job_ids[],
signed long timeout,
int dispose,
char *error_diagnosis,
size_t error_diag_len
```

**);**

```
int drmaa_wait(
const char *job_id,
char *job_id_out,
size_t job_id_out_len,
int *stat,
signed long timeout,
drmaa_attr_values_t **rusage,
char *error_diagnosis,
size_t error_diagnois_len
```

**);**

```
int drmaa_wifaborted(
int *aborted,
int stat,
char *error_diagnosis,
size_t error_diag_len
```

**);**

```
int drmaa_wifexited(
int *exited,
int stat,
char *error_diagnosis,
size_t error_diag_len
```

**);**

```
int drmaa_wifsignaled(
int *signaled,
int stat,
char *error_diagnosis,
size_t error_diag_len
```

**);**

```
int drmaa_wcoredump(
int *core_dumped,
int stat,
char *error_diagnosis,
size_t error_diag_len
```

**);**

```
int drmaa_wexitstatus(
int *exit_status,
int stat,
char *error_diagnosis,
size_t error_diag_len
```

**);**

```
int drmaa_wtermsig(
char *signal,
size_t signal_len,
int stat,
char *error_diagnosis,
size_t error_diag_len
```

**);**

```

```

## DESCRIPTION

**The drmaa\_synchronize() function blocks the calling thread until all jobs specified in** *job\_ids*  **have failed or finished execution. If** *job\_ids* **contains 'DRMAA\_JOB\_IDS\_SESSION\_ALL', then this**  **function waits for all jobs submitted during this DRMAA session. The** *job\_ids* **pointer array** **must be** *NULL* **terminated.**

**To prevent blocking indefinitely in this call, the caller may use the** *timeout***, specifying**  **how many seconds to wait for this call to complete before timing out. The special value** **DRMAA\_TIMEOUT\_WAIT\_FOREVER can be used to wait indefinitely for a result. The special value** **DRMAA\_TIMEOUT\_NO\_WAIT can be used to return immediately.**  **If the call exits before** *timeout* **seconds, all the specified jobs have completed or** **the calling thread received an interrupt.  In both cases, the return code is DRMAA\_ERRNO\_EXIT\_TIMEOUT.**

**The** *dispose* **parameter specifies how to treat reaping information.**  **If '0' is passed to this parameter, job finish information will still be available when**  [*drmaa\_wait*(3)](/drmaa_wait/3.md) is used. If '1' is passed,  [*drmaa\_wait*(3)](/drmaa_wait/3.md) will be unable to access this job's finish information.

### drmaa\_wait()

The drmaa\_wait() function blocks the calling thread until a job fails or finishes execution. This routine is modeled on the  *wait4*(3) routine.  If the special string 'DRMAA\_JOB\_IDS\_SESSION\_ANY' is passed as *job\_id*, this routine  will wait for any job from the session. Otherwise the *job\_id* must be the job identifier of a job or array job task that was submitted during the session.

To prevent blocking indefinitely in this call, the caller may use *timeout*, specifying  how many seconds to wait for this call to complete before timing out. The special value DRMAA\_TIMEOUT\_WAIT\_FOREVER can be to wait indefinitely for a result. The special value DRMAA\_TIMEOUT\_NO\_WAIT can be used to return immediately.  If the call exits before *timeout* seconds have passed, all the specified jobs have completed or the calling thread received an interrupt.  In both cases, the return code is DRMAA\_ERRNO\_EXIT\_TIMEOUT.

The routine reaps jobs on a successful call, so any subsequent calls to  [*drmaa\_wait*(3)](/drmaa_wait/3.md) will fail returning a DRMAA\_ERRNO\_INVALID\_JOB error, meaning that the job has already been reaped.  This error is the same as if the job were unknown. Returning due to an elapsed timeout or an interrupt does not cause the job information to be reaped.  This means that, in this case, it is possible to issue  [*drmaa\_wait*(3)](/drmaa_wait/3.md) multiple times for the same *job\_id*.

If *job\_id\_out* is not a null pointer, then on return from a successful  [*drmaa\_wait*(3)](/drmaa_wait/3.md) call, up to *job\_id\_out\_len* characters from the job id of the failed  or finished job are returned.

If *stat* is not a null pointer, then on return from a successful  [*drmaa\_wait*(3)](/drmaa_wait/3.md) call, the status of the job is stored in the integer pointed to by *stat*. *stat* indicates whether job failed or finished and other information. The  information encoded in the integer value can be accessed via  [*drmaa\_wifaborted*(3)](/drmaa_wifaborted/3.md) [*drmaa\_wifexited*(3)](/drmaa_wifexited/3.md) [*drmaa\_wifsignaled*(3)](/drmaa_wifsignaled/3.md) [*drmaa\_wcoredump*(3)](/drmaa_wcoredump/3.md) [*drmaa\_wexitstatus*(3)](/drmaa_wexitstatus/3.md) [*drmaa\_wtermsig*(3)](/drmaa_wtermsig/3.md).

If *rusage* is not a null pointer, then on return from a successful [*drmaa\_wait*(3)](/drmaa_wait/3.md) call, a summary of the  resources used by the terminated job is returned in form of a DRMAA  values  string  vector. The entries in the DRMAA values string vector can be extracted using [*drmaa\_get\_next\_attr\_value*(3)](/drmaa_get_next_attr_value/3.md). Each string returned by [*drmaa\_get\_next\_attr\_value*(3)](/drmaa_get_next_attr_value/3.md) will be of the format \<name\>=\<value\>, where \<name\> and \<value\> specify name and amount of resources consumed by the job, respectively.  See *accounting*(5) for an explanation of the resource information.

### drmaa\_wifaborted()

The drmaa\_wifaborted() function evaluates into the integer pointed to by *aborted* a non-zero value if *stat* was returned from a job that ended before entering the  running state.

### drmaa\_wifexited()

The drmaa\_wifexited() function evaluates into the integer pointed to by *exited* a  non-zero value if *stat* was returned from a job that terminated normally. A  zero value can also indicate that although the job has terminated normally, an exit  status is not available, or that it is not known whether the job terminated normally.  In both cases  [*drmaa\_wexitstatus*(3)](/drmaa_wexitstatus/3.md) will not provide exit status information. A non-zero value returned in *exited*  indicates more detailed diagnosis can be provided by means of  [*drmaa\_wifsignaled*(3)](/drmaa_wifsignaled/3.md), [*drmaa\_wtermsig*(3)](/drmaa_wtermsig/3.md) and  [*drmaa\_wcoredump*(3)](/drmaa_wcoredump/3.md).

### drmaa\_wifsignaled()

The drmaa\_wifsignaled() function evaluates into the integer pointed to by *signaled*  a non-zero value if *stat* was returned for a job that terminated due to the receipt of a  signal. A zero value can also indicate that although the job has terminated due to the receipt of  a signal, the signal is not available, or it is not known whether the job terminated due to  the receipt of a signal. In both cases  [*drmaa\_wtermsig*(3)](/drmaa_wtermsig/3.md) will not provide signal information. A non-zero value returned in *signaled*  indicates signal information can be retrieved by means of  [*drmaa\_wtermsig*(3)](/drmaa_wtermsig/3.md).

### drmaa\_wcoredump()

If [*drmaa\_wifsignaled*(3)](/drmaa_wifsignaled/3.md) returned a non-zero value in the *signaled* parameter, the drmaa\_wcoredump() function evaluates into the  integer pointed to by *core\_dumped* a non-zero value if a core image of the terminated  job was created.

### drmaa\_wexitstatus()

If  [*drmaa\_wifexited*(3)](/drmaa_wifexited/3.md) returned a non-zero value in the *exited* parameter, the drmaa\_wexitstatus() function evaluates into the integer pointed to by *exit\_code* the exit code that the job passed to  [*exit*(2)](/exit/2.md) or the value that the child process returned from main.

### drmaa\_wtermsig()

If  [*drmaa\_wifsignaled*(3)](/drmaa_wifsignaled/3.md) returned a non-zero value in the *signaled* parameter, the drmaa\_wtermsig() function evaluates  into *signal* up to *signal\_len* characters of a string representation of the signal  that caused the termination of the job. For signals declared by POSIX.1, the symbolic names  are returned (e.g., SIGABRT, SIGALRM). For signals not declared by POSIX, any other string  may be returned.

## ENVIRONMENTAL VARIABLES

- **SGE\_ROOT**

  Specifies the location of the Sun Grid Engine standard configuration files.

- **SGE\_CELL**

  If set, specifies the default Sun Grid Engine cell to be used. To address a Sun Grid Engine cell Sun Grid Engine uses (in the order of precedence):

  The name of the cell specified in the environment variable SGE\_CELL, if it is set.

  The name of the default cell, i.e. **default**.

- **SGE\_DEBUG\_LEVEL**

  If set, specifies that debug information should be written to stderr. In addition the level of detail in which debug information is generated is defined.

- **SGE\_QMASTER\_PORT**

  If set, specifies the tcp port on which [*sge\_qmaster*(8)](/sge_qmaster/8.md) is expected to listen for communication requests. Most installations will use a services map entry instead to define that port.

## RETURN VALUES

Upon successful completion, drmaa\_run\_job(), drmaa\_run\_bulk\_jobs(), and drmaa\_get\_next\_job\_id() return DRMAA\_ERRNO\_SUCCESS. Other values indicate an error. Up to *error\_diag\_len* characters of error related diagnosis  information is then provided in the buffer *error\_diagnosis*.

## ERRORS

The drmaa\_synchronize(), drmaa\_wait(), drmaa\_wifexited(), drmaa\_wexitstatus(),  drmaa\_wifsignaled(), drmaa\_wtermsig(), drmaa\_wcoredump(), and drmaa\_wifaborted() will fail if:

### DRMAA\_ERRNO\_INTERNAL\_ERROR

Unexpected or internal DRMAA error, like system call failure, etc.

### DRMAA\_ERRNO\_DRM\_COMMUNICATION\_FAILURE

Could not contact DRM system for this request.

### DRMAA\_ERRNO\_AUTH\_FAILURE

The specified request is not processed successfully due to authorization failure.

### DRMAA\_ERRNO\_INVALID\_ARGUMENT

The input value for an argument is invalid.

### DRMAA\_ERRNO\_NO\_ACTIVE\_SESSION

Failed because there is no active session.

### DRMAA\_ERRNO\_NO\_MEMORY

Failed allocating memory.

The drmaa\_synchronize() and drmaa\_wait() functions will fail if:

### DRMAA\_ERRNO\_EXIT\_TIMEOUT

Time-out condition.

### DRMAA\_ERRNO\_INVALID\_JOB

The job specified by the does not exist.

The drmaa\_wait() will fail if:

### DRMAA\_ERRNO\_NO\_RUSAGE

This error code is returned by drmaa\_wait() when a job  has finished but no rusage and stat data could be provided.

## SEE ALSO

[*drmaa\_submit*(3)](/drmaa_submit/3.md).
