emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r113430: Fix porting bug to older POSIXish platforms


From: Paul Eggert
Subject: [Emacs-diffs] trunk r113430: Fix porting bug to older POSIXish platforms.
Date: Tue, 16 Jul 2013 07:05:52 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 113430
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/14862
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Tue 2013-07-16 00:05:41 -0700
message:
  Fix porting bug to older POSIXish platforms.
  
  * sysdep.c (emacs_pipe): New function, that implements
  pipe2 (fd, O_CLOEXEC) even on hosts that lack O_CLOEXEC.
  This should port better to CentOS 5 and to Mac OS X 10.6.
  All calls to pipe2 changed.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/alloc.c                    alloc.c-20091113204419-o5vbwnq5f7feedwu-252
  src/callproc.c                 callproc.c-20091113204419-o5vbwnq5f7feedwu-248
  src/emacs.c                    emacs.c-20091113204419-o5vbwnq5f7feedwu-241
  src/lisp.h                     lisp.h-20091113204419-o5vbwnq5f7feedwu-253
  src/nsterm.m                   nsterm.m-20091113204419-o5vbwnq5f7feedwu-8747
  src/process.c                  process.c-20091113204419-o5vbwnq5f7feedwu-462
  src/sysdep.c                   sysdep.c-20091113204419-o5vbwnq5f7feedwu-448
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-07-16 06:39:49 +0000
+++ b/src/ChangeLog     2013-07-16 07:05:41 +0000
@@ -1,5 +1,11 @@
 2013-07-16  Paul Eggert  <address@hidden>
 
+       Fix porting bug to older POSIXish platforms (Bug#14862).
+       * sysdep.c (emacs_pipe): New function, that implements
+       pipe2 (fd, O_CLOEXEC) even on hosts that lack O_CLOEXEC.
+       This should port better to CentOS 5 and to Mac OS X 10.6.
+       All calls to pipe2 changed.
+
        Prefer list1 (X) to Fcons (X, Qnil) when building lists.
        This makes the code easier to read and the executable a bit smaller.
        Do not replace all calls to Fcons that happen to create lists,

=== modified file 'src/alloc.c'
--- a/src/alloc.c       2013-07-07 18:00:14 +0000
+++ b/src/alloc.c       2013-07-16 07:05:41 +0000
@@ -4741,7 +4741,7 @@
      Unfortunately, we cannot use NULL_DEVICE here, as emacs_write may
      not validate p in that case.  */
 
-  if (pipe2 (fd, O_CLOEXEC) == 0)
+  if (emacs_pipe (fd) == 0)
     {
       bool valid = emacs_write (fd[1], (char *) p, 16) == 16;
       emacs_close (fd[1]);

=== modified file 'src/callproc.c'
--- a/src/callproc.c    2013-07-16 06:39:49 +0000
+++ b/src/callproc.c    2013-07-16 07:05:41 +0000
@@ -524,7 +524,7 @@
     {
 #ifndef MSDOS
       int fd[2];
-      if (pipe2 (fd, O_CLOEXEC) != 0)
+      if (emacs_pipe (fd) != 0)
        {
          int pipe_errno = errno;
          emacs_close (filefd);

=== modified file 'src/emacs.c'
--- a/src/emacs.c       2013-07-16 06:39:49 +0000
+++ b/src/emacs.c       2013-07-16 07:05:41 +0000
@@ -985,7 +985,7 @@
         use a pipe for synchronization.  The parent waits for the child
         to close its end of the pipe (using `daemon-initialized')
         before exiting.  */
-      if (pipe2 (daemon_pipe, O_CLOEXEC) != 0)
+      if (emacs_pipe (daemon_pipe) != 0)
        {
          fprintf (stderr, "Cannot pipe!\n");
          exit (1);

=== modified file 'src/lisp.h'
--- a/src/lisp.h        2013-07-12 17:30:48 +0000
+++ b/src/lisp.h        2013-07-16 07:05:41 +0000
@@ -4094,6 +4094,7 @@
 extern void emacs_backtrace (int);
 extern _Noreturn void emacs_abort (void) NO_INLINE;
 extern int emacs_open (const char *, int, int);
+extern int emacs_pipe (int[2]);
 extern int emacs_close (int);
 extern ptrdiff_t emacs_read (int, char *, ptrdiff_t);
 extern ptrdiff_t emacs_write (int, const char *, ptrdiff_t);

=== modified file 'src/nsterm.m'
--- a/src/nsterm.m      2013-07-16 06:39:49 +0000
+++ b/src/nsterm.m      2013-07-16 07:05:41 +0000
@@ -4142,7 +4142,7 @@
 
   if (selfds[0] == -1)
     {
-      if (pipe2 (selfds, O_CLOEXEC) != 0)
+      if (emacs_pipe (selfds) != 0)
         {
           fprintf (stderr, "Failed to create pipe: %s\n",
                    emacs_strerror (errno));

=== modified file 'src/process.c'
--- a/src/process.c     2013-07-16 06:39:49 +0000
+++ b/src/process.c     2013-07-16 07:05:41 +0000
@@ -1651,11 +1651,11 @@
   else
 #endif /* HAVE_PTYS */
     {
-      if (pipe2 (sv, O_CLOEXEC) != 0)
+      if (emacs_pipe (sv) != 0)
        report_file_error ("Creating pipe", Qnil);
       inchannel = sv[0];
       forkout = sv[1];
-      if (pipe2 (sv, O_CLOEXEC) != 0)
+      if (emacs_pipe (sv) != 0)
        {
          int pipe_errno = errno;
          emacs_close (inchannel);
@@ -1667,7 +1667,7 @@
     }
 
 #ifndef WINDOWSNT
-  if (pipe2 (wait_child_setup, O_CLOEXEC) != 0)
+  if (emacs_pipe (wait_child_setup) != 0)
     report_file_error ("Creating pipe", Qnil);
 #endif
 

=== modified file 'src/sysdep.c'
--- a/src/sysdep.c      2013-07-12 14:31:42 +0000
+++ b/src/sysdep.c      2013-07-16 07:05:41 +0000
@@ -2201,6 +2201,20 @@
   return fd < 0 ? 0 : fdopen (fd, mode);
 }
 
+/* Create a pipe for Emacs use.  */
+
+int
+emacs_pipe (int fd[2])
+{
+  int result = pipe2 (fd, O_CLOEXEC);
+  if (! O_CLOEXEC && result == 0)
+    {
+      fcntl (fd[0], F_SETFD, FD_CLOEXEC);
+      fcntl (fd[1], F_SETFD, FD_CLOEXEC);
+    }
+  return result;
+}
+
 /* Approximate posix_close and POSIX_CLOSE_RESTART well enough for Emacs.
    For the background behind this mess, please see Austin Group defect 529
    <http://austingroupbugs.net/view.php?id=529>.  */


reply via email to

[Prev in Thread] Current Thread [Next in Thread]