summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_file.c
diff options
context:
space:
mode:
authorKonstantin Pavlov <thresh@nginx.com>2023-05-10 10:29:16 -0700
committerKonstantin Pavlov <thresh@nginx.com>2023-05-10 10:29:16 -0700
commit69235c513277c64b513447d9b92c3c03d616f577 (patch)
tree0780c92ba28d92b547c85ea0bee5e3040e14dee2 /src/nxt_file.c
parentb9bc222021e77bbdfb12576b3e315b962cf6b399 (diff)
parentfaf97dc06058de1c929af33a68adb34d3932b374 (diff)
downloadunit-1.30.0-1.tar.gz
unit-1.30.0-1.tar.bz2
Merged with the default branch.1.30.0-1
Diffstat (limited to 'src/nxt_file.c')
-rw-r--r--src/nxt_file.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/nxt_file.c b/src/nxt_file.c
index a3fcda76..6f1a93e4 100644
--- a/src/nxt_file.c
+++ b/src/nxt_file.c
@@ -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_int_t