mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-07 04:10:27 -08:00
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. Fixes: debbugs:14862
This commit is contained in:
parent
e6c005c5f8
commit
c7ddc792b7
8 changed files with 28 additions and 7 deletions
|
|
@ -1,5 +1,11 @@
|
|||
2013-07-16 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
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,
|
||||
|
|
|
|||
|
|
@ -4741,7 +4741,7 @@ valid_pointer_p (void *p)
|
|||
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]);
|
||||
|
|
|
|||
|
|
@ -524,7 +524,7 @@ usage: (call-process PROGRAM &optional INFILE DESTINATION DISPLAY &rest ARGS) *
|
|||
{
|
||||
#ifndef MSDOS
|
||||
int fd[2];
|
||||
if (pipe2 (fd, O_CLOEXEC) != 0)
|
||||
if (emacs_pipe (fd) != 0)
|
||||
{
|
||||
int pipe_errno = errno;
|
||||
emacs_close (filefd);
|
||||
|
|
|
|||
|
|
@ -985,7 +985,7 @@ main (int argc, char **argv)
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -4094,6 +4094,7 @@ extern void init_random (void);
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -4142,7 +4142,7 @@ ns_term_init (Lisp_Object display_name)
|
|||
|
||||
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));
|
||||
|
|
|
|||
|
|
@ -1651,11 +1651,11 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
|
|||
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 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
|
|||
}
|
||||
|
||||
#ifndef WINDOWSNT
|
||||
if (pipe2 (wait_child_setup, O_CLOEXEC) != 0)
|
||||
if (emacs_pipe (wait_child_setup) != 0)
|
||||
report_file_error ("Creating pipe", Qnil);
|
||||
#endif
|
||||
|
||||
|
|
|
|||
14
src/sysdep.c
14
src/sysdep.c
|
|
@ -2201,6 +2201,20 @@ emacs_fopen (char const *file, char const *mode)
|
|||
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>. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue