---
name: "drmaa_session"
section: "3"
platform: "linux"
package: "gridengine-drmaa-dev"
version: "8.1.9+dfsg-13.1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/drmaa_session"
---

# drmaa\_session(3)

Start/finish Grid Engine DRMAA session

## NAME

drmaa\_init, drmaa\_exit - Start/finish Grid Engine DRMAA session

## SYNOPSIS

**#include "drmaa.h"**

```
int drmaa_init(
const char *contact,
char *error_diagnosis,
size_t error_diag_len
```

**);**

```
int drmaa_exit(
char *error_diagnosis,
size_t error_diag_len
```

**);**

## DESCRIPTION

### drmaa\_init()

The drmaa\_init() function initializes the Grid Engine DRMAA API library for all threads  of the process and creates a new DRMAA session. This routine must be called once before  any other DRMAA call, except for  [*drmaa\_version*(3)](/drmaa_version/3.md), [*drmaa\_get\_DRM\_system*(3)](/drmaa_get_DRM_system/3.md), and  [*drmaa\_get\_DRMAA\_implementation*(3)](/drmaa_get_DRMAA_implementation/3.md). Except for the above listed functions, no DRMAA functions may be called before the drmaa\_init() function *completes*.  Any DRMAA function which is called before the drmaa\_init() function completes will return a DRMAA\_ERRNO\_NO\_ACTIVE\_SESSION error. *Contact* is an implementation dependent string which may be used to  specify which Grid Engine cell to use. If  *contact*  is NULL, the default Grid Engine cell will be used. In the 1.0 implementation  *contact* may have the following value: **session=***session\_id***.  To** **determine the session\_id, the** [*drmaa\_get\_contact*(3)](/drmaa_get_contact/3.md) function should be called after the session has already been initialized.  By passing the **session=***session\_id* **string to the drmaa\_init() function,** **instead of creating a new session, DRMAA will attempt to reconnect to the** **session indicated by the** *session\_id***.  The result of reconnecting to a** **previous session is that all jobs previously submitted in that session that** **are still running will be available in the DRMAA session.  Note, however,** **that jobs which ended before the call to drmaa\_init() may not be available or** **may have no associated exit information or resource usage data.**

### drmaa\_exit()

**The drmaa\_exit() function closes the DRMAA session for all threads and must be** **called before process termination.  The drmaa\_exit() function may be called only** **once by a single thread in the process and may only be called after the** **drmaa\_init() function has completed.  Any DRMAA function, other than** [*drmaa\_init*(3)](/drmaa_init/3.md), which is called after the drmaa\_exit() function completes will return a DRMAA\_ERRNO\_NO\_ACTIVE\_SESSION error.

The drmaa\_exit() function does necessary clean up of the DRMAA session state, including unregistering from the *qmaster*(8). If the drmaa\_exit() function is not called, the qmaster will store events for the DRMAA client until the connection times out, causing extra work for the qmaster and consuming system resources.

Submitted jobs are not affected by the drmaa\_exit() function.

## ENVIRONMENTAL VARIABLES

- **SGE\_ROOT**

  Specifies the location of the Grid Engine standard configuration files.

- **SGE\_CELL**

  If set, specifies the default Grid Engine cell to be used. To address a Grid Engine cell 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 the sge\_qmaster 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\_init() and drmaa\_exit() 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\_init() and drmaa\_exit() functions can fail with:

- **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.

The drmaa\_init() function can fail with:

- **DRMAA\_ERRNO\_INVALID\_CONTACT\_STRING**

  Initialization failed due to invalid contact string.

- **DRMAA\_ERRNO\_DEFAULT\_CONTACT\_STRING\_ERROR**

  Could not use the default contact string to connect to DRM system.

- **DRMAA\_ERRNO\_DRMS\_INIT\_FAILED**

  Initialization failed due to failure to init DRM system.

- **DRMAA\_ERRNO\_ALREADY\_ACTIVE\_SESSION**

  Initialization failed due to existing DRMAA session.

- **DRMAA\_ERRNO\_NO\_MEMORY**

  Failed allocating memory.

The drmaa\_exit() function can fail with:

- **DRMAA\_ERRNO\_NO\_ACTIVE\_SESSION**

  Failed because there is no active session.

- **DRMAA\_ERRNO\_DRMS\_EXIT\_ERROR**

  DRM system disengagement failed.

## SEE ALSO

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