DEC C
Run-Time Library Reference Manual for OpenVMS Systems


Previous Contents Index


vswprintf

Writes output to the stream under control of the wide-character format string.

Format

#include <wchar.h>

int vswprintf (wchar_t *s, size_t n, const wchar_t *format, va_list arg);


Arguments

s

A pointer to a multibyte character sequence.

n

The maximum number of bytes that comprise the multibyte character.

format

A pointer to a wide-character string containing the format specifications. For more information about format and conversion specifications and their corresponding arguments, see Chapter 2.

arg

A variable list of the items needed for output.

Description

This function is equivalent to the swprintf function, with the variable argument list replaced by the arg argument. Initialize arg with the va_start macro, and possibly with subsequent va_arg calls.

See also swprintf in this section.


Return Values

n The number of wide characters written.
Negative value Indicates an error. The function sets errno to one of the following:
  • EILSEQ -- Invalid character detected.
  • EINVAL -- Insufficient arguments.
  • ENOMEM -- Not enough memory available for conversion.
  • ERANGE -- Floating-point calculations overflow.
  • EVMSERR -- Nontranslatable VMS error. vaxc$errno contains the VMS error code. This might indicate that conversion to a numeric value failed because of overflow.

The function can also set errno to the following as a result of errors returned from the I/O subsystem:

  • EBADF -- The file descriptor is not valid.
  • EIO -- I/O error.
  • ENOSPC -- No free space on the device containing the file.
  • ENXIO -- Device does not exist.
  • EPIPE -- Broken pipe.
  • ESPIPE -- Illegal seek in a file opened for append.
  • EVMSERR -- Nontranslatable VMS error. vaxc$errno contains the VMS error code. This indicates that an I/O error occurred for which there is no equivalent C error code.

vwprintf

Writes output to an array of wide characters under control of the wide-character format string.

Format

#include <wchar.h>

int vwprintf (const wchar_t *format, va_list arg);


Arguments

format

A pointer to a wide-character string containing the format specifications. For more information about format and conversion specifications and their corresponding arguments, see Chapter 2.

arg

The variable list of items needed for output.

Description

This function is equivalent to the wprintf function, with the variable argument list replaced by the arg argument. Initialize arg with the va_start macro, and possibly with subsequent va_arg calls. The vwprintf function does not invoke the va_end macro.

See also wprintf in this section.


Return Values

x The number of wide characters written, not counting the terminating null wide character.
Negative value Indicates an error. Either n or more wide characters were requested to be written, or a conversion error occurred, in which case errno is set to EILSEQ.

vsprintf

Prints formatted output based on an argument list.

This function is the same as the sprintf function except that instead of being called with a variable number of arguments, it is called with an argument list that has been initialized by va_start (and possibly with subsequent va_arg calls).


Format

#include <stdio.h>

int vsprintf (char *str, const char *format, va_list arg);


Arguments

str

A pointer to a string that will receive the formatted output. This string is assumed to be large enough to hold the output.

format

A pointer to a character string that contains the format specification. For more information about format and conversion specifications and their corresponding arguments, see Chapter 2.

arg

A list of expressions whose resultant types correspond to the conversion specifications given in the format specifications.

Return Value

x The number of bytes written.
Negative value Indicates an output error occurred.The function sets errno . For a list of possible errno values set, see fprintf in this section.

wait

Checks the status of the child process before exiting. A child process is terminated when the parent process terminates.

Format

#include <wait.h>

pid_t wait (int *status);


Argument

status

The address of a location to receive the final status of the terminated child. The child can set the status with the exit function and the parent can retrieve this value by specifying status.

Description

This function suspends the parent process until the final status of a terminated child is returned from the child.

On OpenVMS Version 7.0 and higher systems, the wait function is equivalent to waitpid( 0, status, 0 ) if you include <wait.h> and compile with the _posix_exit feature-test macro set (either with /DEFINE=_POSIX_EXIT or with #define _posix_exit at the top of your file, before any file inclusions).


Return Values

x The process ID (PID) of the terminated child. If more than one child process was created, wait will return the PID of the terminated child that was most recently created. Subsequent calls will return the PID of the next most recently created, but terminated, child.
--1 No child process was spawned.

wait3

Waits for a child process to stop or terminate.

Format

#include <wait.h>

pid_t wait3 (int *status_location, int options, struct rusage *resource_usage);


Arguments

status_location

A pointer to a location that contains the termination status of the child process as defined in the <wait.h> header file.

Beginning with OpenVMS Version 7.2, when compiled with the _VMS_WAIT macro defined, this function puts the OpenVMS completion code of the child process at the address specified in the status_location argument.

options

Flags that modify the behavior of the function. These flags are defined in the Description section.

resource_usage

The location of a structure that contains the resource utilization information for terminated child processes.

Description

This function suspends the calling process until the request is completed, and redefines it so that only the calling thread is suspended.

The options argument modifies the behavior of the function. You can combine the flags for the options argument by specifying their bitwise inclusive OR. The flags are:
WNOWAIT Specifies that the process whose status is returned in status_location is kept in a waitable state. You can wait for the process again with the same results.
WNOHANG Prevents the suspension of the calling process. If there are child processes that stopped or terminated, one is chosen and the waitpid function returns its process ID, as when you do not specify the WNOHANG flag. If there are no terminated processes (that is, if waitpid suspends the calling process without the WNOHANG flag), 0 (zero) is returned. Because you can never wait for process 0, there is no confusion arising from this return.
WUNTRACED Specifies that the call return additional information when the child processes of the current process stop because the child process received a SIGTTIN, SIGTTOU, SIGSTOP, or SIGTSTOP signal.

If the wait3 function returns because the status of a child process is available, the process ID of the child process is returned. Information is stored in the location pointed to by status_location, if this pointer is not null.

The value stored in the location pointed to by status_location is 0 (zero) only if the status is returned from a terminated child process that did one of the following:

Regardless of the status_location value, you can define this information using the macros defined in the <wait.h> header file, which evaluate to integral expressions. In the following macro descriptions, the status_value argument is equal to the integer value pointed to by the status_location argument:
wifexited (status_value ) Evaluates to a nonzero value if status was returned for a child process that terminated normally.
wexitstatus (status_value ) If the value of wifexited (status_value ) is nonzero, this macro evaluates to the low-order 8 bits of the status argument that the child process passed to the _exit or exit function, or to the value the child process returned from the main function.
wifsignaled (status_value ) Evaluates to nonzero value if status was returned for a child process that terminated due to the receipt of a signal that was not caught.
wtermsig (status_value ) If the value of wifsignaled (status_value ) is nonzero, this macro evaluates to the number of the signal that caused the termination of the child process.
wifstopped (status_value ) Evaluates to a nonzero value if status was returned for a child process that is currently stopped.
wstopsig (status_value ) If the value of wifstopped (status_value ) is nonzero, this macro evaluates to the number of the signal that caused the child process to stop.
wifcontinued (status_value ) Evaluates to a nonzero value if status was returned for a child process that has continued.

If the information stored at the location pointed to by status_location was stored there by a call to wait3 that specified the wuntraced flag, one of the following macros evaluates to a nonzero value:

If the information stored in the location pointed to by status_location resulted from a call to wait3 without the wuntraced flag specified, one of the following macros evaluates to a nonzero value:

The wait3 function provides compatibility with BSD systems. The resource_usage argument points to a location that contains resource usage information for the child processes as defined in the <resource.h> header file.

If a parent process terminates without waiting for all of its child processes to terminate, the remaining child processes is assigned a parent process ID equal to the process ID of the init process.

See also exit , -exit , and init in this section.


Return Values

0 Indicates success. There are no stopped or exited child processes, the WNOHANG option is specified.
x The process_id of the child process. Status of a child process is available.
--1 Indicates an error; errno is set to one of the following values:
  • ECHILD -- There are no child processes to wait for.
  • EINTR -- Terminated by receipt of a signal caught by the calling process.
  • EFAULT -- The status_location or resource_usage argument points to a location outside of the address space of the process.
  • EINVAL--- The value of the options argument is not valid.

wait4

Waits for a child process to stop or terminate.

Format

#include <wait.h>

pid_t wait4 (pid_t process_id, union wait *status_location, int options, struct rusage *resource_usage);


Arguments

status_location

A pointer to a location that contains the termination status of the child process as defined in the <wait.h> header file.

Beginning with OpenVMS Version 7.2, when compiled with the _VMS_WAIT macro defined, this function puts the OpenVMS completion code of the child process at the address specified in the status_location argument.

process_id

The child process or set of child processes.

options

Flags that modify the behavior of the function. These flags are defined in the Description section.

resource_usage

The location of a structure that contains the resource utilization information for terminated child processes.

Description

This function suspends the calling process until the request is completed.

The process_id argument allows the calling process to gather status from a specific set of child processes, according to the following rules:
If the process_id is Then status is requested
Equal to --1 For any child process. In this respect, the waitpid function is equivalent to the wait function.
Greater than 0 For a single child process and specifies the process ID.

The wait4 function only returns the status of a child process from this set.

The options argument to the wait4 function modifies the behavior of the function. You can combine the flags for the options argument by specifying their bitwise-inclusive OR. The flags are:
WNOWAIT Specifies that the process whose status is returned in status_location is kept in a waitable state. You can wait for the process again with the same results.
WNOHANG Prevents the suspension of the calling process. If there are child processes that stopped or terminated, one is chosen and the waitpid function returns its process ID, as when you do not specify the WNOHANG flag. If there are no terminated processes (that is, if waitpid suspends the calling process without the WNOHANG flag), 0 is returned. Because you can never wait for process 0, there is no confusion arising from this return.
WUNTRACED Specifies that the call return additional information when the child processes of the current process stop because the child process received a SIGTTIN, SIGTTOU, SIGSTOP, or SIGTSTOP signal.

If the wait4 function returns because the status of a child process is available, the process ID of the child process is returned. Information is stored in the location pointed to by status_location, if this pointer is not null.

The value stored in the location pointed to by status_location is 0 only if the status is returned from a terminated child process that did one of the following:

Regardless of the status_location value, you can define this information using the macros defined in the <wait.h> header file, which evaluate to integral expressions. In the following macro descriptions, status_value is equal to the integer value pointed to by status_location:
wifexited (status_value ) Evaluates to a nonzero value if status was returned for a child process that terminated normally.
wexitstatus (status_value ) If the value of wifexited (status_value ) is nonzero, this macro evaluates to the low-order 8 bits of the status argument that the child process passed to the _exit or exit function, or to the value the child process returned from the main function.
wifsignaled (status_value ) Evaluates to nonzero value if status was returned for a child process that terminated due to the receipt of a signal that was not caught.
wtermsig (status_value ) If the value of wifsignaled (status_value ) is nonzero, this macro evaluates to the number of the signal that caused the termination of the child process.
wifstopped (status_value ) Evaluates to a nonzero value if status was returned for a child process that is currently stopped.
wstopsig (status_value ) If the value of wifstopped (status_value ) is nonzero, this macro evaluates to the number of the signal that caused the child process to stop.
wifcontinued (status_value ) Evaluates to a nonzero value if status was returned for a child process that has continued.

If the information stored at the location pointed to by status_location was stored there by a call to wait4 that specified the wuntraced flag, one of the following macros evaluates to a nonzero value:

If the information stored in the location pointed to by status_location resulted from a call to wait4 without the wuntraced flag specified, one of the following macros evaluates to a nonzero value:

The wait4 function is similar to the wait3 function. However, the wait4 function waits for a specific child as indicated by the process_id argument. The resource_usage argument points to a location that contains resource usage information for the child processes as defined in the <resource.h> header file.

See also exit and _exit in this section.


Return Values

0 Indicates success. There are no stopped or exited child processes, the WNOHANG option is specified.
x The process_id of the child process. Status of a child process is available.
--1 Indicates an error; errno is set to one of the following values:
  • ECHILD -- There are no child processes to wait for.
  • EINTR -- Terminated by receipt of a signal caught by the calling process.
  • EFAULT -- The status_location or resource_usage argument points to a location outside of the address space of the process.
  • EINVAL--- The value of the options argument is not valid.


Previous Next Contents Index