Add nxt_file_stdout().
This is analogous to the nxt_file_stderr() function and will be used in a subsequent commit. This function redirects stdout to a given file descriptor. Reviewed-by: Alejandro Colomar <alx@nginx.com> Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
This commit is contained in:
@@ -563,6 +563,25 @@ nxt_file_redirect(nxt_file_t *file, nxt_fd_t fd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* nxt_file_stdout() redirects the stdout descriptor to the file. */
|
||||||
|
|
||||||
|
nxt_int_t
|
||||||
|
nxt_file_stdout(nxt_file_t *file)
|
||||||
|
{
|
||||||
|
nxt_thread_log_debug("dup2(%FD, %FD, \"%FN\")",
|
||||||
|
file->fd, STDOUT_FILENO, file->name);
|
||||||
|
|
||||||
|
if (dup2(file->fd, STDOUT_FILENO) != -1) {
|
||||||
|
return NXT_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
nxt_thread_log_alert("dup2(%FD, %FD, \"%FN\") failed %E",
|
||||||
|
file->fd, STDOUT_FILENO, file->name, nxt_errno);
|
||||||
|
|
||||||
|
return NXT_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* nxt_file_stderr() redirects the stderr descriptor to the file. */
|
/* nxt_file_stderr() redirects the stderr descriptor to the file. */
|
||||||
|
|
||||||
nxt_int_t
|
nxt_int_t
|
||||||
|
|||||||
@@ -191,6 +191,7 @@ NXT_EXPORT FILE *nxt_file_fopen(nxt_task_t *task, const char *pathname,
|
|||||||
NXT_EXPORT void nxt_file_fclose(nxt_task_t *task, FILE *fp);
|
NXT_EXPORT void nxt_file_fclose(nxt_task_t *task, FILE *fp);
|
||||||
|
|
||||||
NXT_EXPORT nxt_int_t nxt_file_redirect(nxt_file_t *file, nxt_fd_t fd);
|
NXT_EXPORT nxt_int_t nxt_file_redirect(nxt_file_t *file, nxt_fd_t fd);
|
||||||
|
NXT_EXPORT nxt_int_t nxt_file_stdout(nxt_file_t *file);
|
||||||
NXT_EXPORT nxt_int_t nxt_file_stderr(nxt_file_t *file);
|
NXT_EXPORT nxt_int_t nxt_file_stderr(nxt_file_t *file);
|
||||||
NXT_EXPORT nxt_int_t nxt_stderr_start(void);
|
NXT_EXPORT nxt_int_t nxt_stderr_start(void);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user