United States |
Previous | Contents | Index |
Prints formatted output based on an argument list.
#include <stdio.h>int vfprintf (FILE *file_ptr, const char *format, va_list arg);
file_ptr
A pointer to the file to which the output is directed.format
A pointer to a string containing 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.
See the vprintf and vsprintf functions in this section.See Chapter 2 for information on format specifiers.
x The number of bytes written. Negative value Indicates an output error. The function sets errno . For a list of possible errno values set, see fprintf in this section.
Writes output to the stream under control of the wide-character format string.
#include <wchar.h>int vfwprintf (FILE *stream, const wchar_t *format, va_list arg);
stream
A file pointer.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.
This function is equivalent to the fwprintf 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) from <stdarg.h> .If the stream pointed to by stream has no orientation, vfwprintf makes the stream wide-oriented.
See also fwprintf in this section
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.
The following example shows the use of the vfwprintf function in a general error reporting routine.
#include <stdarg.h> #include <stdio.h> #include <wchar.h> void error(char *function_name, wchar_t *format, ...); { va_list args; va_start(args, format); /* print out name of function causing error */ fwprintf(stderr, L"ERROR in %s: ", function_name); /* print out remainder of message */ vfwprintf(stderr, format, args); va_end(args); }
Prints formatted output based on an argument list.This function is the same as the printf 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 the va_start macro (and possibly with subsequent va_arg calls) from <stdarg.h> .
#include <stdio.h>int vprintf (const char *format, va_list arg);
format
A pointer to the string containing the format specification. 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.
See the vfprintf and vsprintf functions this section.See Chapter 2 for information on format specifiers.
x The number of bytes written. Negative value Indicates an output error. The function sets errno . For a list of possible errno values set, see fprintf in this section.
Writes output to the stream under control of the wide-character format string.
#include <wchar.h>int vswprintf (wchar_t *s, size_t n, const wchar_t *format, va_list arg);
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.
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.
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.
Writes output to an array of wide characters under control of the wide-character format string.
#include <wchar.h>int vwprintf (const wchar_t *format, va_list arg);
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.
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.
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.
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).
#include <stdio.h>int vsprintf (char *str, const char *format, va_list arg);
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.
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.
Checks the status of the child process before exiting. A child process is terminated when the parent process terminates.
#include <wait.h>pid_t wait (int *status);
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.
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).
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.
Waits for a child process to stop or terminate.
#include <wait.h>pid_t wait3 (int *status_location, int options, struct rusage *resource_usage);
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.
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:
- Returned 0 from the main function.
- Passed 0 as the status argument to the _exit or exit function.
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:
- WIFEXITED (*status_value)
- WIFSIGNALED (*status_value)
- WIFSTOPPED (*status_value)
- WIFCONTINUED (*status_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:
- WIFEXITED (*status_value)
- WIFSIGNALED (*status_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.
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 |
|