1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

O_CLOEXEC usage

* libguile/objcodes.c (scm_load_objcode):
* libguile/scmsigs.c (start_signal_delivery_thread):
* libguile/threads.c (guilify_self_1): Use O_CLOEXEC.
This commit is contained in:
Andy Wingo 2011-06-16 18:27:57 +02:00
parent 3d458a81c6
commit 32f94bf258
3 changed files with 4 additions and 17 deletions

View file

@ -295,7 +295,7 @@ SCM_DEFINE (scm_load_objcode, "load-objcode", 1, 0, 0,
SCM_VALIDATE_STRING (1, file); SCM_VALIDATE_STRING (1, file);
c_file = scm_to_locale_string (file); c_file = scm_to_locale_string (file);
fd = open (c_file, O_RDONLY); fd = open (c_file, O_RDONLY | O_CLOEXEC);
free (c_file); free (c_file);
if (fd < 0) SCM_SYSERROR; if (fd < 0) SCM_SYSERROR;

View file

@ -39,10 +39,6 @@
#include "libguile/validate.h" #include "libguile/validate.h"
#include "libguile/scmsigs.h" #include "libguile/scmsigs.h"
#ifdef HAVE_IO_H
#include <io.h> /* for mingw _pipe() */
#endif
#ifdef HAVE_PROCESS_H #ifdef HAVE_PROCESS_H
#include <process.h> /* for mingw */ #include <process.h> /* for mingw */
#endif #endif
@ -61,7 +57,6 @@
/* This weird comma expression is because Sleep is void under Windows. */ /* This weird comma expression is because Sleep is void under Windows. */
#define sleep(sec) (Sleep ((sec) * 1000), 0) #define sleep(sec) (Sleep ((sec) * 1000), 0)
#define usleep(usec) (Sleep ((usec) / 1000), 0) #define usleep(usec) (Sleep ((usec) / 1000), 0)
#define pipe(fd) _pipe (fd, 256, O_BINARY)
#endif #endif
#include <full-write.h> #include <full-write.h>
@ -208,7 +203,7 @@ start_signal_delivery_thread (void)
scm_i_pthread_mutex_lock (&signal_delivery_thread_mutex); scm_i_pthread_mutex_lock (&signal_delivery_thread_mutex);
if (pipe (signal_pipe) != 0) if (pipe2 (signal_pipe, O_CLOEXEC) != 0)
scm_syserror (NULL); scm_syserror (NULL);
signal_thread = scm_spawn_thread (signal_delivery_thread, NULL, signal_thread = scm_spawn_thread (signal_delivery_thread, NULL,
scm_handle_by_message, scm_handle_by_message,

View file

@ -39,6 +39,7 @@
#endif #endif
#include <assert.h> #include <assert.h>
#include <fcntl.h>
#include <nproc.h> #include <nproc.h>
#include "libguile/validate.h" #include "libguile/validate.h"
@ -57,15 +58,6 @@
#include "libguile/strings.h" #include "libguile/strings.h"
#include "libguile/weaks.h" #include "libguile/weaks.h"
#ifdef __MINGW32__
#ifndef ETIMEDOUT
# define ETIMEDOUT WSAETIMEDOUT
#endif
# include <fcntl.h>
# include <process.h>
# define pipe(fd) _pipe (fd, 256, O_BINARY)
#endif /* __MINGW32__ */
#include <full-read.h> #include <full-read.h>
@ -538,7 +530,7 @@ guilify_self_1 (struct GC_stack_base *base)
t.sleep_object = SCM_BOOL_F; t.sleep_object = SCM_BOOL_F;
t.sleep_fd = -1; t.sleep_fd = -1;
if (pipe (t.sleep_pipe) != 0) if (pipe2 (t.sleep_pipe, O_CLOEXEC) != 0)
/* FIXME: Error conditions during the initialization phase are handled /* FIXME: Error conditions during the initialization phase are handled
gracelessly since public functions such as `scm_init_guile ()' gracelessly since public functions such as `scm_init_guile ()'
currently have type `void'. */ currently have type `void'. */