[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]
Base Operating System and Extensions Technical Reference, Volume 1

getevars Subroutine

Purpose

Gets environment of a process.

Library

Standard C library (libc.a)

Syntax

#include <procinfo.h>
#include <sys/types.h>
int getevars (processBuffer, bufferLen, argsBuffer, argsLen)
struct procsinfo *processBuffer;
int bufferLen;
char *argsBuffer;
int argsLen;

Description

The getevars subroutine returns the environment that was passed to a command when it was started. Only one process can be examined per call to getevars.

The getevars subroutine uses the pi_pid field of processBuffer to determine which process to look for. bufferLen should be set to size of struct procsinfo. Parameters are returned in argsBuffer, which should be allocated by the caller. The size of this array must be given in argsLen.

On return, argsBuffer consists of a succession of strings, each terminated with a null character (ascii `\0'). Hence, two consecutive NULLs indicate the end of the list.

Note: The arguments may be changed asynchronously by the process, but results are not guaranteed to be consistent.

Parameters

processBuffer Specifies the address of a procsinfo structure, whose pi_pid field should contain the pid of the process that is to be looked for.
bufferLen Specifies the size of a single procsinfo structure,
argsBuffer Specifies the address of an array of characters to be filled with a series of strings representing the parameters that are needed. An extra NULL character marks the end of the list. This array must be allocated by the caller.
argsLen Specifies the size of the argsBuffer array. No more than argsLen characters are returned.

Return Values

If successful, the getevars subroutine returns zero. Otherwise, a value of -1 is returned and the errno global variable is set to indicate the error.

Error Codes

The getevars subroutine does not succeed if the following are true:

EBADF The specified process does not exist.
EFAULT The copy operation to the buffer was not successful or the processBuffer or argsBuffer parameters are invalid.
EINVAL The bufferLen parameter does not contain the size of a single procsinfo structure.

Implementation Specifics

This subroutine is part of the Base Operating System (BOS) Runtime.

Related Information

The getargs, getpid, getpgrp, getppid, or getthrds subroutines.

The ps command.


[ Next Article | Previous Article | Book Contents | Library Home | Legal | Search ]