diff options
author | Andy Wingo <wingo@pobox.com> | 2012-02-08 20:09:36 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2012-02-14 22:47:15 +0100 |
commit | f503c1d6be378c3351b7011b07c4fa32230698f1 (patch) | |
tree | a30ec5e813bec4d9befdce3b9a349cf918544c38 | |
parent | 7565b9fc09242b0adfd81f1390e75ced3f894078 (diff) | |
download | guile-f503c1d6be378c3351b7011b07c4fa32230698f1.tar.gz |
primitive-move->fdes preserves CLOEXEC flag
* libguile/ioext.c (scm_primitive_move_to_fdes): Use dup3 to preserve
the CLOEXEC flag, if appropriate.
-rw-r--r-- | libguile/ioext.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/libguile/ioext.c b/libguile/ioext.c index 94b0f4f0f..1ecbf4db7 100644 --- a/libguile/ioext.c +++ b/libguile/ioext.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2006, 2011 Free Software Foundation, Inc. +/* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2006, 2011, 2012 Free Software Foundation, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License @@ -254,12 +254,10 @@ SCM_DEFINE (scm_primitive_move_to_fdes, "primitive-move->fdes", 2, 0, 0, stream = SCM_FSTREAM (port); old_fd = stream->fdes; new_fd = scm_to_int (fd); - if (old_fd == new_fd) - { - return SCM_BOOL_F; - } + if (old_fd == new_fd) + return SCM_BOOL_F; scm_evict_ports (new_fd); - rv = dup2 (old_fd, new_fd); + rv = dup3 (old_fd, new_fd, stream->cloexec_p ? O_CLOEXEC : 0); if (rv == -1) SCM_SYSERROR; stream->fdes = new_fd; |