int fd = (UX_open ("/dev/tty", O_RDWR, 0));
if (fd >= 0)
{
- UX_ioctl (fd, TIOCNOTTY, 0);
- UX_close (fd);
+ (void) UX_ioctl (fd, TIOCNOTTY, 0);
+ (void) UX_close (fd);
}
#endif
return (setpgrp (0, 0));
UX_dup2 (int fd, int fd2)
{
if (fd != fd2)
- UX_close (fd2);
+ (void) UX_close (fd2);
{
int result = (UX_fcntl (fd, F_DUPFD, fd2));
if ((result < 0) && (errno == EINVAL))
return (UX_fcntl (fd, F_CLOSEM));
#elif ((defined (HAVE_FCNTL)) && (defined (F_MAXFD)))
int max_fd = (UX_fcntl ((-1), F_MAXFD));
- int status;
+ int status = 0, error = 0;
if (max_fd < 0) return (max_fd);
while (fd <= max_fd)
- if (((status = (UX_close (fd++))) < 0) && (errno != EBADF))
- return (status);
- return (0);
+ if (((UX_close (fd++)) < 0) && (errno != EBADF))
+ status = (-1), error = errno;
+ errno = error;
+ return (status);
#else
int fd_limit = (UX_SC_OPEN_MAX ());
- int status;
+ int status = 0, error = 0;
while (fd < fd_limit)
- if (((status = (UX_close (fd++))) < 0) && (errno != EBADF))
- return (status);
- return (0);
+ if (((UX_close (fd++)) < 0) && (errno != EBADF))
+ status = (-1), error = errno;
+ errno = error;
+ return (status);
#endif
}
if ((SLAVE_PTY_P (filename)) && (!UX_setup_slave_pty (fd)))
{
int xerrno = errno;
- UX_close (fd);
+ /* FIXME: Need to check for EINTR. */
+ (void) UX_close (fd);
error_system_call (xerrno, syscall_open);
}
#endif
transaction_commit ();
#else
transaction_commit ();
+ /* FIXME: Need to check for EINTR. */
fd = (UX_open (filename, (O_WRONLY | O_TRUNC), MODE_REG));
if (fd >= 0)
- STD_VOID_SYSTEM_CALL (syscall_close, (UX_close (fd)));
+ (void) UX_close (fd);
#endif
return (0);
}
static void
protect_fd_close (void * ap)
{
- UX_close (* ((int *) ap));
+ (void) UX_close (* ((int *) ap));
}
static void
{
if (! (CHANNEL_INTERNAL (channel)))
{
- STD_VOID_SYSTEM_CALL
- (syscall_close, (UX_close (CHANNEL_DESCRIPTOR (channel))));
+ if (0 > (UX_close (CHANNEL_DESCRIPTOR (channel))))
+ switch (errno)
+ {
+ case EINTR: deliver_pending_interrupts (); break;
+ case EBADF: error_system_call (errno, syscall_close); break;
+ }
MARK_CHANNEL_CLOSED (channel);
}
}
{
if (! (CHANNEL_INTERNAL (channel)))
{
- UX_close (CHANNEL_DESCRIPTOR (channel));
+ (void) UX_close (CHANNEL_DESCRIPTOR (channel));
MARK_CHANNEL_CLOSED (channel);
}
}
}
/* Close all file descriptors not used by the child. */
- /* FIXME: Handle EINTR? */
if (channel_in_type == process_channel_type_none)
- if ((UX_close (STDIN_FILENO)) < 0) goto kill_child;
+ (void) UX_close (STDIN_FILENO);
if (channel_out_type == process_channel_type_none)
- if ((UX_close (STDOUT_FILENO)) < 0) goto kill_child;
+ (void) UX_close (STDOUT_FILENO);
if (channel_err_type == process_channel_type_none)
- if ((UX_close (STDERR_FILENO)) < 0) goto kill_child;
+ (void) UX_close (STDERR_FILENO);
/* Assumption: STDIN_FILENO = 0, STDOUT_FILENO = 1, STDERR_FILENO = 2. */
- if ((UX_closefrom (3)) < 0) goto kill_child;
+ (void) UX_closefrom (3);
/* Put the signal mask and handlers in a normal state. */
UX_initialize_child_signals ();
}
if ((UX_access (slave_name, (R_OK | W_OK))) < 0)
{
- UX_close (fd);
+ /* FIXME: Need to handle EINTR. */
+ (void) UX_close (fd);
continue;
}
MAKE_CHANNEL (fd, channel_type_unix_pty_master, (*master_fd) =);