fsautoproc
Basic file transformation automation management utility
Loading...
Searching...
No Matches
fd.h File Reference

File descriptor output redirection for child processes. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  fdset_s
 A set of file descriptors for redirecting writes to stdout and stderr from child processes to log files. More...
 

Functions

int fdinit (struct fdset_s *fds, unsigned int id)
 Initializes stdout/stderr files used for redirecting output from a child process. The file descriptors are stored in the provided file descriptor set. The files are opened in write-only mode and are created if they do not exist. If either file fails to open, the function will return -1 and both file descriptors will be set to -1.
 
void fdclose (struct fdset_s *fds)
 Closes the stdout and stderr file descriptors in the provided file descriptor set using close(2). If either file descriptor is already closed, the function will not attempt to close it again.
 

Detailed Description

File descriptor output redirection for child processes.

Function Documentation

◆ fdclose()

void fdclose ( struct fdset_s * fds)

Closes the stdout and stderr file descriptors in the provided file descriptor set using close(2). If either file descriptor is already closed, the function will not attempt to close it again.

Parameters
fdsThe file descriptor set to close
Note
The file descriptors must be initialized with fdinit before calling this function.
Here is the caller graph for this function:

◆ fdinit()

int fdinit ( struct fdset_s * fds,
unsigned int id )

Initializes stdout/stderr files used for redirecting output from a child process. The file descriptors are stored in the provided file descriptor set. The files are opened in write-only mode and are created if they do not exist. If either file fails to open, the function will return -1 and both file descriptors will be set to -1.

Parameters
fdsThe file descriptor set to initialize
idUnique identifier to append to the file name
Returns
0 if both files were opened successfully, otherwise -1
Here is the call graph for this function:
Here is the caller graph for this function: