committed by
Keith Winstein
parent
f7be5c8cec
commit
dd941df19d
+1
-1
@@ -1,3 +1,3 @@
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
SUBDIRS = third src scripts man
|
||||
SUBDIRS = src scripts man
|
||||
EXTRA_DIST = autogen.sh ocb-license.html README.md
|
||||
|
||||
@@ -160,49 +160,6 @@ AS_IF([test x"$with_utempter" != xno],
|
||||
|
||||
AC_SEARCH_LIBS([compress], [z], , [AC_MSG_ERROR([Unable to find zlib.])])
|
||||
|
||||
AC_ARG_WITH([skalibs],
|
||||
[AS_HELP_STRING([--with-skalibs[=DIR]],
|
||||
[root directory of skalibs installation])],
|
||||
[with_skalibs=$withval
|
||||
AS_IF([test x"$withval" != xyes],
|
||||
[SKALIBS_CPPFLAGS="-I$withval/include"
|
||||
SKALIBS_LDFLAGS="-L$withval/lib"])],
|
||||
[with_skalibs=no])
|
||||
AC_ARG_WITH([skalibs-include],
|
||||
[AS_HELP_STRING([--with-skalibs-include=DIR],
|
||||
[specify exact include dir for skalibs headers])],
|
||||
[SKALIBS_CPPFLAGS="-I$withval"])
|
||||
AC_ARG_WITH([skalibs-libdir],
|
||||
[AS_HELP_STRING([--with-skalibs-libdir=DIR],
|
||||
[specify exact library dir for skalibs libraries])],
|
||||
[SKALIBS_LDFLAGS="-L$withval"])
|
||||
|
||||
STDDJB_CPPFLAGS=""
|
||||
STDDJB_LDFLAGS=""
|
||||
AS_IF([test x"$with_skalibs" != xno],
|
||||
[AX_CHECK_LIBRARY([SKALIBS], [selfpipe.h], [stddjb], [],
|
||||
[AC_MSG_ERROR([Unable to find skalibs.])])
|
||||
AC_SUBST([STDDJB_CPPFLAGS], ["$SKALIBS_CPPFLAGS"])
|
||||
AC_SUBST([STDDJB_LDFLAGS], ["$SKALIBS_LDFLAGS -lstddjb"])])
|
||||
|
||||
have_signalfd="no"
|
||||
AC_CHECK_DECL([signalfd],
|
||||
[have_signalfd="yes"
|
||||
AC_DEFINE([HAVE_SIGNALFD], [1],
|
||||
[Define if signalfd is available.])],
|
||||
, [[#include <sys/signalfd.h>]])
|
||||
|
||||
AS_IF([test x"$have_signalfd" = xno],
|
||||
[AC_DEFINE([USE_LIBSTDDJB], [1],
|
||||
[Define if we should call functions from libstddjb (part of skalibs)])])
|
||||
AM_CONDITIONAL([USE_LIBSTDDJB],
|
||||
[test x"$have_signalfd" = xno])
|
||||
|
||||
# Build the bundled libstddjb only if we'll use it and we don't have a
|
||||
# path for skalibs.
|
||||
AM_CONDITIONAL([COND_THIRD_LIBSTDDJB],
|
||||
[test x"$have_signalfd" = xno && test x"$with_skalibs" = xno])
|
||||
|
||||
# Checks for header files.
|
||||
AC_CHECK_HEADERS([arpa/inet.h fcntl.h langinfo.h limits.h locale.h netinet/in.h stddef.h stdint.h inttypes.h stdlib.h string.h sys/ioctl.h sys/resource.h sys/socket.h sys/stat.h sys/time.h termios.h unistd.h wchar.h wctype.h], [], [AC_MSG_ERROR([Missing required header file.])])
|
||||
|
||||
@@ -303,8 +260,6 @@ PKG_CHECK_MODULES([protobuf], [protobuf])
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
third/Makefile
|
||||
third/libstddjb/Makefile
|
||||
src/Makefile
|
||||
src/crypto/Makefile
|
||||
src/frontend/Makefile
|
||||
|
||||
Vendored
-15
@@ -174,18 +174,3 @@ License: GPL3+
|
||||
.
|
||||
On Debian systems, the complete text of the GNU General
|
||||
Public License version 3 can be found in "/usr/share/common-licenses/GPL-3".
|
||||
|
||||
Files: third/libstddjb/*
|
||||
Copyright: 2011-2012 Laurent Bercot <ska-skaware@skarnet.org>
|
||||
License: ISC
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
.
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
# This must be set in Makefile.am for dependency tracking to work.
|
||||
if COND_THIRD_LIBSTDDJB
|
||||
STDDJB_LDFLAGS += $(top_builddir)/third/libstddjb/libstddjb.a
|
||||
STDDJB_CPPFLAGS += -I$(top_srcdir)/third/libstddjb
|
||||
endif
|
||||
|
||||
AM_CXXFLAGS = $(WARNING_CXXFLAGS) $(PICKY_CXXFLAGS) $(HARDEN_CFLAGS) $(MISC_CXXFLAGS)
|
||||
AM_LDFLAGS = $(HARDEN_LDFLAGS)
|
||||
|
||||
@@ -24,13 +18,13 @@ parse_CPPFLAGS = -I$(srcdir)/../terminal -I$(srcdir)/../util
|
||||
parse_LDADD = ../terminal/libmoshterminal.a ../util/libmoshutil.a -lutil
|
||||
|
||||
termemu_SOURCES = termemu.cc
|
||||
termemu_CPPFLAGS = -I$(srcdir)/../terminal -I$(srcdir)/../util -I$(srcdir)/../statesync -I../protobufs $(STDDJB_CPPFLAGS)
|
||||
termemu_LDADD = ../terminal/libmoshterminal.a ../util/libmoshutil.a ../statesync/libmoshstatesync.a ../protobufs/libmoshprotos.a -lutil $(STDDJB_LDFLAGS) $(TINFO_LIBS) $(protobuf_LIBS)
|
||||
termemu_CPPFLAGS = -I$(srcdir)/../terminal -I$(srcdir)/../util -I$(srcdir)/../statesync -I../protobufs
|
||||
termemu_LDADD = ../terminal/libmoshterminal.a ../util/libmoshutil.a ../statesync/libmoshstatesync.a ../protobufs/libmoshprotos.a -lutil $(TINFO_LIBS) $(protobuf_LIBS)
|
||||
|
||||
ntester_SOURCES = ntester.cc
|
||||
ntester_CPPFLAGS = -I$(srcdir)/../util -I$(srcdir)/../statesync -I$(srcdir)/../terminal -I$(srcdir)/../network -I$(srcdir)/../crypto -I../protobufs $(protobuf_CFLAGS)
|
||||
ntester_LDADD = ../statesync/libmoshstatesync.a ../terminal/libmoshterminal.a ../network/libmoshnetwork.a ../crypto/libmoshcrypto.a ../protobufs/libmoshprotos.a ../util/libmoshutil.a -lutil -lm $(protobuf_LIBS)
|
||||
|
||||
benchmark_SOURCES = benchmark.cc
|
||||
benchmark_CPPFLAGS = -I$(srcdir)/../util -I$(srcdir)/../statesync -I$(srcdir)/../terminal -I../protobufs -I$(srcdir)/../frontend -I$(srcdir)/../crypto -I$(srcdir)/../network $(STDDJB_CPPFLAGS) $(protobuf_CFLAGS)
|
||||
benchmark_CPPFLAGS = -I$(srcdir)/../util -I$(srcdir)/../statesync -I$(srcdir)/../terminal -I../protobufs -I$(srcdir)/../frontend -I$(srcdir)/../crypto -I$(srcdir)/../network $(protobuf_CFLAGS)
|
||||
benchmark_LDADD = ../frontend/terminaloverlay.o ../statesync/libmoshstatesync.a ../terminal/libmoshterminal.a ../protobufs/libmoshprotos.a ../network/libmoshnetwork.a ../crypto/libmoshcrypto.a ../util/libmoshutil.a $(STDDJB_LDFLAGS) -lutil -lm $(TINFO_LIBS) $(protobuf_LIBS)
|
||||
|
||||
@@ -44,11 +44,6 @@
|
||||
#include "locale_utils.h"
|
||||
#include "fatal_assert.h"
|
||||
|
||||
/* For newer skalibs */
|
||||
extern "C" {
|
||||
const char *PROG = "benchmark";
|
||||
}
|
||||
|
||||
const int ITERATIONS = 100000;
|
||||
|
||||
using namespace Terminal;
|
||||
|
||||
@@ -51,11 +51,6 @@
|
||||
#include "locale_utils.h"
|
||||
#include "select.h"
|
||||
|
||||
/* For newer skalibs */
|
||||
extern "C" {
|
||||
const char *PROG = "termemu";
|
||||
}
|
||||
|
||||
const size_t buf_size = 16384;
|
||||
|
||||
void emulate_terminal( int fd );
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
# This must be set in Makefile.am for dependency tracking to work.
|
||||
if COND_THIRD_LIBSTDDJB
|
||||
STDDJB_LDFLAGS += $(top_builddir)/third/libstddjb/libstddjb.a
|
||||
STDDJB_CPPFLAGS += -I$(top_srcdir)/third/libstddjb
|
||||
endif
|
||||
|
||||
AM_CPPFLAGS = -I$(srcdir)/../statesync -I$(srcdir)/../terminal -I$(srcdir)/../network -I$(srcdir)/../crypto -I../protobufs -I$(srcdir)/../util $(STDDJB_CPPFLAGS) $(TINFO_CFLAGS) $(protobuf_CFLAGS)
|
||||
AM_CPPFLAGS = -I$(srcdir)/../statesync -I$(srcdir)/../terminal -I$(srcdir)/../network -I$(srcdir)/../crypto -I../protobufs -I$(srcdir)/../util $(TINFO_CFLAGS) $(protobuf_CFLAGS)
|
||||
AM_CXXFLAGS = $(WARNING_CXXFLAGS) $(PICKY_CXXFLAGS) $(HARDEN_CFLAGS) $(MISC_CXXFLAGS)
|
||||
AM_LDFLAGS = $(HARDEN_LDFLAGS)
|
||||
LDADD = ../crypto/libmoshcrypto.a ../network/libmoshnetwork.a ../statesync/libmoshstatesync.a ../terminal/libmoshterminal.a ../util/libmoshutil.a ../protobufs/libmoshprotos.a $(STDDJB_LDFLAGS) -lm $(TINFO_LIBS) $(protobuf_LIBS)
|
||||
LDADD = ../crypto/libmoshcrypto.a ../network/libmoshnetwork.a ../statesync/libmoshstatesync.a ../terminal/libmoshterminal.a ../util/libmoshutil.a ../protobufs/libmoshprotos.a -lm $(TINFO_LIBS) $(protobuf_LIBS)
|
||||
|
||||
mosh_server_LDADD = $(LDADD) -lutil
|
||||
|
||||
|
||||
@@ -30,11 +30,6 @@
|
||||
#include <curses.h>
|
||||
#include <term.h>
|
||||
|
||||
/* For newer skalibs */
|
||||
extern "C" {
|
||||
const char *PROG = "mosh-client";
|
||||
}
|
||||
|
||||
void usage( const char *argv0 ) {
|
||||
fprintf( stderr, "mosh-client (%s)\n", PACKAGE_STRING );
|
||||
fprintf( stderr, "Copyright 2012 Keith Winstein <mosh-devel@mit.edu>\n" );
|
||||
|
||||
@@ -67,11 +67,6 @@
|
||||
|
||||
#include "networktransport.cc"
|
||||
|
||||
/* For newer skalibs */
|
||||
extern "C" {
|
||||
const char *PROG = "mosh-server";
|
||||
}
|
||||
|
||||
typedef Network::Transport< Terminal::Complete, Network::UserStream > ServerConnection;
|
||||
|
||||
void serve( int host_fd,
|
||||
|
||||
@@ -2,8 +2,4 @@ AM_CXXFLAGS = $(WARNING_CXXFLAGS) $(PICKY_CXXFLAGS) $(HARDEN_CFLAGS) $(MISC_CXXF
|
||||
|
||||
noinst_LIBRARIES = libmoshutil.a
|
||||
|
||||
libmoshutil_a_SOURCES = locale_utils.cc locale_utils.h swrite.cc swrite.h dos_assert.h fatal_assert.h sigfd.h select.h select.cc
|
||||
|
||||
if !USE_LIBSTDDJB
|
||||
libmoshutil_a_SOURCES += sigfd.cc
|
||||
endif
|
||||
libmoshutil_a_SOURCES = locale_utils.cc locale_utils.h swrite.cc swrite.h dos_assert.h fatal_assert.h select.h select.cc
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
Mosh: the mobile shell
|
||||
Copyright 2012 Keith Winstein
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/signalfd.h>
|
||||
|
||||
#include "fatal_assert.h"
|
||||
|
||||
static sigset_t caught;
|
||||
static int fd = -1;
|
||||
|
||||
#define SIGNALFD_FLAGS ( SFD_NONBLOCK | SFD_CLOEXEC )
|
||||
|
||||
int sigfd_init( void )
|
||||
{
|
||||
if ( fd != -1 ) {
|
||||
errno = EBUSY;
|
||||
return -1;
|
||||
}
|
||||
sigemptyset( &caught );
|
||||
fd = signalfd( -1, &caught, SIGNALFD_FLAGS );
|
||||
return fd;
|
||||
}
|
||||
|
||||
int sigfd_trap( int sig )
|
||||
{
|
||||
/* The callers all fatal_assert on error, so we can do the same here.
|
||||
We still return 'int' in order to have the same API as libstddjb. */
|
||||
fatal_assert( 0 <= fd );
|
||||
fatal_assert( 0 <= sigaddset( &caught, sig ) );
|
||||
fatal_assert( 0 <= sigprocmask( SIG_BLOCK, &caught, NULL ) );
|
||||
fatal_assert( 0 <= signalfd( fd, &caught, SIGNALFD_FLAGS ) );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sigfd_read( void )
|
||||
{
|
||||
int r;
|
||||
struct signalfd_siginfo si;
|
||||
|
||||
do {
|
||||
r = read( fd, &si, sizeof( si ) );
|
||||
} while ( ( r == -1 ) && ( errno == EINTR ) );
|
||||
|
||||
if ( r == -1 ) {
|
||||
if ( errno == EAGAIN || errno == EWOULDBLOCK )
|
||||
/* No signal available */
|
||||
return 0;
|
||||
return -1;
|
||||
} else if ( r != sizeof( si ) ) {
|
||||
/* Should never happen?
|
||||
Includes r = 0, i.e. end of file */
|
||||
errno = EPIPE;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return (int) si.ssi_signo;
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
Mosh: the mobile shell
|
||||
Copyright 2012 Keith Winstein
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Uses either signalfd or libstddjb's selfpipe to receive signals as part of
|
||||
an event loop.
|
||||
|
||||
selfpipe already does a fine job of interfacing to signalfd. But Debian and
|
||||
Ubuntu want us to depend on the skalibs-dev package rather than build
|
||||
libstddjb ourselves. That would be fine except that skalibs-dev has static
|
||||
libraries only, and they aren't built with -fPIC. This interferes with
|
||||
building mosh-{client,server} as position-independent executables, which
|
||||
is a desirable security measure.
|
||||
|
||||
So we have our own wrapper, which invokes either signalfd or selfpipe. And
|
||||
we build it ourselves with our own flags, because it's part of the Mosh
|
||||
project proper. */
|
||||
|
||||
#ifndef SIGFD_HPP
|
||||
#define SIGFD_HPP
|
||||
|
||||
#if USE_LIBSTDDJB
|
||||
|
||||
extern "C" {
|
||||
#include "selfpipe.h"
|
||||
}
|
||||
|
||||
#define sigfd_init selfpipe_init
|
||||
#define sigfd_trap selfpipe_trap
|
||||
#define sigfd_read selfpipe_read
|
||||
|
||||
#else
|
||||
|
||||
int sigfd_init( void );
|
||||
int sigfd_trap( int sig );
|
||||
int sigfd_read( void );
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,4 +0,0 @@
|
||||
SUBDIRS =
|
||||
if COND_THIRD_LIBSTDDJB
|
||||
SUBDIRS += libstddjb
|
||||
endif
|
||||
@@ -1,15 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2011-2012 Laurent Bercot <ska-skaware@skarnet.org>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
@@ -1,35 +0,0 @@
|
||||
AM_CFLAGS = -pedantic -Wall -Wextra -pipe $(HARDEN_CFLAGS)
|
||||
|
||||
noinst_LIBRARIES = libstddjb.a
|
||||
|
||||
libstddjb_a_SOURCES = \
|
||||
allreadwrite.h \
|
||||
coe.c \
|
||||
djbunix.h \
|
||||
error.h \
|
||||
fd_close.c \
|
||||
fd_read.c \
|
||||
fd_write.c \
|
||||
gccattributes.h \
|
||||
ndelay_on.c \
|
||||
nsig.h \
|
||||
pipe_internal.c \
|
||||
sanitize_read.c \
|
||||
selfpipe-internal.h \
|
||||
selfpipe.h \
|
||||
selfpipe_finish.c \
|
||||
selfpipe_init.c \
|
||||
selfpipe_internal.c \
|
||||
selfpipe_read.c \
|
||||
selfpipe_trap.c \
|
||||
selfpipe_trapset.c \
|
||||
selfpipe_untrap.c \
|
||||
sig.h \
|
||||
sig_restoreto.c \
|
||||
skalibs-config.h \
|
||||
skasig_dfl.c \
|
||||
skasigaction.c \
|
||||
sysdeps.h \
|
||||
uint64.h
|
||||
|
||||
EXTRA_DIST = COPYING
|
||||
@@ -1,25 +0,0 @@
|
||||
/* ISC license. */
|
||||
|
||||
#ifndef ALLREADWRITE_H
|
||||
#define ALLREADWRITE_H
|
||||
|
||||
typedef int iofunc_t (int, char *, unsigned int) ;
|
||||
typedef iofunc_t *iofunc_t_ref ;
|
||||
|
||||
typedef unsigned int alliofunc_t (int, char *, unsigned int) ;
|
||||
typedef alliofunc_t *alliofunc_t_ref ;
|
||||
|
||||
extern int sanitize_read (int) ;
|
||||
extern unsigned int allreadwrite (iofunc_t_ref, int, char *, unsigned int) ;
|
||||
|
||||
extern int fd_read (int, char *, unsigned int) ;
|
||||
extern int fd_write (int, char const *, unsigned int) ;
|
||||
|
||||
extern int fd_recv (int, char *, unsigned int, unsigned int) ;
|
||||
extern int fd_send (int, char const *, unsigned int, unsigned int) ;
|
||||
|
||||
extern unsigned int allread (int, char *, unsigned int) ;
|
||||
extern unsigned int allwrite (int, char const *, unsigned int) ;
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,11 +0,0 @@
|
||||
/* ISC license. */
|
||||
|
||||
#include <fcntl.h>
|
||||
#include "djbunix.h"
|
||||
|
||||
int coe (int fd)
|
||||
{
|
||||
register int flags = fcntl(fd, F_GETFD, 0) ;
|
||||
if (flags < 0) return -1 ;
|
||||
return fcntl(fd, F_SETFD, flags | FD_CLOEXEC) ;
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
/* ISC license. */
|
||||
|
||||
#ifndef DJBUNIX_H
|
||||
#define DJBUNIX_H
|
||||
|
||||
#define DJBUNIX_FLAG_NB 0x01U
|
||||
#define DJBUNIX_FLAG_COE 0x02U
|
||||
|
||||
extern int coe (int) ;
|
||||
extern int ndelay_on (int) ;
|
||||
extern int pipe_internal (int *, unsigned int) ;
|
||||
#define pipenb(p) pipe_internal(p, DJBUNIX_FLAG_NB)
|
||||
#define pipecoe(p) pipe_internal(p, DJBUNIX_FLAG_COE)
|
||||
#define pipenbcoe(p) pipe_internal(p, DJBUNIX_FLAG_NB|DJBUNIX_FLAG_COE)
|
||||
extern int fd_close (int) ;
|
||||
|
||||
#endif
|
||||
@@ -1,14 +0,0 @@
|
||||
/* ISC license. */
|
||||
|
||||
#ifndef ERROR_H
|
||||
#define ERROR_H
|
||||
|
||||
#include <errno.h>
|
||||
#include "gccattributes.h"
|
||||
|
||||
extern char const *error_str (int) gccattr_const ;
|
||||
extern int error_temp (int) gccattr_const ;
|
||||
|
||||
#define error_isagain(e) (((e) == EAGAIN) || ((e) == EWOULDBLOCK))
|
||||
|
||||
#endif
|
||||
@@ -1,15 +0,0 @@
|
||||
/* ISC license. */
|
||||
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include "djbunix.h"
|
||||
|
||||
int fd_close (int fd)
|
||||
{
|
||||
register unsigned int i = 0 ;
|
||||
doit:
|
||||
if (!close(fd)) return 0 ;
|
||||
i++ ;
|
||||
if (errno == EINTR) goto doit ;
|
||||
return ((errno == EBADF) && (i > 1)) ? 0 : -1 ;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
/* ISC license. */
|
||||
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include "allreadwrite.h"
|
||||
|
||||
int fd_read (int fd, char *buf, unsigned int len)
|
||||
{
|
||||
register int r ;
|
||||
do r = read(fd, buf, len) ;
|
||||
while ((r == -1) && (errno == EINTR)) ;
|
||||
return r ;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
/* ISC license. */
|
||||
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include "allreadwrite.h"
|
||||
|
||||
int fd_write (int fd, char const *buf, unsigned int len)
|
||||
{
|
||||
register int r ;
|
||||
do r = write(fd, buf, len) ;
|
||||
while ((r == -1) && (errno == EINTR)) ;
|
||||
return r ;
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
/* ISC license. */
|
||||
|
||||
#ifndef GCCATTRIBUTES_H
|
||||
#define GCCATTRIBUTES_H
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
#define gccattr_noreturn __attribute__((__noreturn__))
|
||||
#define gccattr_noinline __attribute__((__noinline__))
|
||||
#define gccattr_inline __attribute__((__always_inline__))
|
||||
#define gccattr_const __attribute__((__const__))
|
||||
#define gccattr_unused __attribute__((__unused__))
|
||||
#define gccattr_used __attribute__((__used__))
|
||||
#define gccattr_weak __attribute__((__weak__))
|
||||
#define gccattr_aligned __attribute__((__aligned__))
|
||||
|
||||
# if (__GNUC__ >= 3) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 96))
|
||||
#define gccattr_malloc __attribute__((__malloc__))
|
||||
#define gccattr_pure __attribute__((__pure__))
|
||||
# else
|
||||
#define gccattr_malloc
|
||||
#define gccattr_pure
|
||||
# endif
|
||||
|
||||
# if (__GNUC__ >= 3)
|
||||
#define gccattr_deprecated __attribute__((__deprecated__))
|
||||
# else
|
||||
#define gccattr_deprecated
|
||||
# endif
|
||||
|
||||
#else
|
||||
|
||||
#define gccattr_noreturn
|
||||
#define gccattr_noinline
|
||||
#define gccattr_inline
|
||||
#define gccattr_const
|
||||
#define gccattr_unused
|
||||
#define gccattr_used
|
||||
#define gccattr_weak
|
||||
#define gccattr_aligned
|
||||
#define gccattr_malloc
|
||||
#define gccattr_pure
|
||||
#define gccattr_deprecated
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef GCCATTR_COMPAT_0_22
|
||||
#define _a_noreturn gccattr_noreturn
|
||||
#define _a_noinline gccattr_noinline
|
||||
#define _a_inline gccattr_inline
|
||||
#define _a_const gccattr_const
|
||||
#define _a_unused gccattr_unused
|
||||
#define _a_used gccattr_used
|
||||
#define _a_weak gccattr_weak
|
||||
#define _a_aligned gccattr_aligned
|
||||
#define _a_malloc gccattr_malloc
|
||||
#define _a_pure gccattr_pure
|
||||
#define _a_deprecated gccattr_deprecated
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,15 +0,0 @@
|
||||
/* ISC license. */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include "djbunix.h"
|
||||
|
||||
#ifndef O_NONBLOCK
|
||||
#define O_NONBLOCK O_NDELAY
|
||||
#endif
|
||||
|
||||
int ndelay_on (int fd)
|
||||
{
|
||||
register int got = fcntl(fd, F_GETFL) ;
|
||||
return (got == -1) ? -1 : fcntl(fd, F_SETFL, got | O_NONBLOCK) ;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
/* ISC license. */
|
||||
|
||||
#ifndef NSIG_H
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#define SKALIBS_NSIG 64
|
||||
|
||||
#ifndef NSIG
|
||||
# define NSIG SKALIBS_NSIG
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,36 +0,0 @@
|
||||
/* ISC license. */
|
||||
|
||||
#include "sysdeps.h"
|
||||
#ifdef HASPIPE2
|
||||
# define _GNU_SOURCE
|
||||
# include <fcntl.h>
|
||||
#else
|
||||
# include <errno.h>
|
||||
#endif
|
||||
|
||||
#include <unistd.h>
|
||||
#include "djbunix.h"
|
||||
|
||||
int pipe_internal (int *p, unsigned int flags)
|
||||
{
|
||||
#ifdef HASPIPE2
|
||||
return pipe2(p, ((flags & DJBUNIX_FLAG_COE) ? O_CLOEXEC : 0) | ((flags & DJBUNIX_FLAG_NB) ? O_NONBLOCK : 0)) ;
|
||||
#else
|
||||
int pi[2] ;
|
||||
if (pipe(pi) < 0) return -1 ;
|
||||
if (flags & DJBUNIX_FLAG_COE)
|
||||
if ((coe(pi[0]) < 0) || (coe(pi[1]) < 0)) goto err ;
|
||||
if (flags & DJBUNIX_FLAG_NB)
|
||||
if ((ndelay_on(pi[0]) < 0) || (ndelay_on(pi[1]) < 0)) goto err ;
|
||||
p[0] = pi[0] ; p[1] = pi[1] ;
|
||||
return 0 ;
|
||||
err:
|
||||
{
|
||||
register int e = errno ;
|
||||
fd_close(pi[1]) ;
|
||||
fd_close(pi[0]) ;
|
||||
errno = e ;
|
||||
}
|
||||
return -1 ;
|
||||
#endif
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
/* ISC license. */
|
||||
|
||||
#include <errno.h>
|
||||
#include "allreadwrite.h"
|
||||
#include "error.h"
|
||||
|
||||
int sanitize_read (int r)
|
||||
{
|
||||
switch (r)
|
||||
{
|
||||
case -1 : return error_isagain(errno) ? (errno = 0, 0) : -1 ;
|
||||
case 0 : return (errno = EPIPE, -1) ;
|
||||
default : return r ;
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
/* ISC license. */
|
||||
|
||||
/* MT-unsafe */
|
||||
|
||||
#ifndef SELFPIPE_INTERNAL_H
|
||||
#define SELFPIPE_INTERNAL_H
|
||||
|
||||
#include <signal.h>
|
||||
#include "sysdeps.h"
|
||||
|
||||
extern sigset_t selfpipe_caught ;
|
||||
|
||||
#ifdef HASSIGNALFD
|
||||
|
||||
extern int selfpipe_fd ;
|
||||
|
||||
#else
|
||||
|
||||
#include "sig.h"
|
||||
|
||||
extern int selfpipe[2] ;
|
||||
#define selfpipe_fd selfpipe[0]
|
||||
|
||||
extern struct skasigaction const selfpipe_ssa ;
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,17 +0,0 @@
|
||||
/* ISC license. */
|
||||
|
||||
/* MT-unsafe */
|
||||
|
||||
#ifndef SELFPIPE_H
|
||||
#define SELFPIPE_H
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
extern int selfpipe_init (void) ;
|
||||
extern int selfpipe_trap (int) ;
|
||||
extern int selfpipe_untrap (int) ;
|
||||
extern int selfpipe_trapset (sigset_t const *) ;
|
||||
extern int selfpipe_read (void) ;
|
||||
extern void selfpipe_finish (void) ;
|
||||
|
||||
#endif
|
||||
@@ -1,35 +0,0 @@
|
||||
/* ISC license. */
|
||||
|
||||
/* MT-unsafe */
|
||||
|
||||
#include <signal.h>
|
||||
#include "sysdeps.h"
|
||||
#include "djbunix.h"
|
||||
#include "selfpipe-internal.h"
|
||||
#include "selfpipe.h"
|
||||
|
||||
#ifdef HASSIGNALFD
|
||||
|
||||
void selfpipe_finish (void)
|
||||
{
|
||||
sigprocmask(SIG_UNBLOCK, &selfpipe_caught, 0) ;
|
||||
sigemptyset(&selfpipe_caught) ;
|
||||
fd_close(selfpipe_fd) ;
|
||||
selfpipe_fd = -1 ;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include "sig.h"
|
||||
#include "nsig.h"
|
||||
|
||||
void selfpipe_finish (void)
|
||||
{
|
||||
sig_restoreto(&selfpipe_caught, NSIG) ;
|
||||
sigemptyset(&selfpipe_caught) ;
|
||||
fd_close(selfpipe[1]) ;
|
||||
fd_close(selfpipe[0]) ;
|
||||
selfpipe[0] = selfpipe[1] = -1 ;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,27 +0,0 @@
|
||||
/* ISC license. */
|
||||
|
||||
/* MT-unsafe */
|
||||
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include "sysdeps.h"
|
||||
#include "selfpipe-internal.h"
|
||||
#include "selfpipe.h"
|
||||
|
||||
#ifdef HASSIGNALFD
|
||||
# include <sys/signalfd.h>
|
||||
#else
|
||||
# include "djbunix.h"
|
||||
#endif
|
||||
|
||||
int selfpipe_init (void)
|
||||
{
|
||||
if (selfpipe_fd >= 0) return (errno = EBUSY, -1) ;
|
||||
sigemptyset(&selfpipe_caught) ;
|
||||
#ifdef HASSIGNALFD
|
||||
selfpipe_fd = signalfd(-1, &selfpipe_caught, SFD_NONBLOCK | SFD_CLOEXEC) ;
|
||||
#else
|
||||
if (pipenbcoe(selfpipe) < 0) return -1 ;
|
||||
#endif
|
||||
return selfpipe_fd ;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/* ISC license. */
|
||||
|
||||
/* MT-unsafe */
|
||||
|
||||
#include <signal.h>
|
||||
#include "sysdeps.h"
|
||||
#include "selfpipe-internal.h"
|
||||
|
||||
sigset_t selfpipe_caught ;
|
||||
|
||||
#ifdef HASSIGNALFD
|
||||
|
||||
int selfpipe_fd = -1 ;
|
||||
|
||||
#else
|
||||
|
||||
#include <errno.h>
|
||||
#include "allreadwrite.h"
|
||||
#include "djbunix.h"
|
||||
|
||||
int selfpipe[2] = { -1, -1 } ;
|
||||
|
||||
static void selfpipe_trigger (int s)
|
||||
{
|
||||
char c = (char)s ;
|
||||
fd_write(selfpipe[1], &c, 1) ;
|
||||
}
|
||||
|
||||
struct skasigaction const selfpipe_ssa = { &selfpipe_trigger, SKASA_NOCLDSTOP | SKASA_MASKALL } ;
|
||||
|
||||
#endif
|
||||
@@ -1,31 +0,0 @@
|
||||
/* ISC license. */
|
||||
|
||||
/* MT-unsafe */
|
||||
|
||||
#include "sysdeps.h"
|
||||
#include "allreadwrite.h"
|
||||
#include "selfpipe-internal.h"
|
||||
#include "selfpipe.h"
|
||||
|
||||
#ifdef HASSIGNALFD
|
||||
|
||||
#include <sys/signalfd.h>
|
||||
|
||||
int selfpipe_read (void)
|
||||
{
|
||||
struct signalfd_siginfo buf ;
|
||||
register int r = sanitize_read(fd_read(selfpipe_fd, (char *)&buf, sizeof(struct signalfd_siginfo))) ;
|
||||
return (r <= 0) ? r : (int)buf.ssi_signo ;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int selfpipe_read (void)
|
||||
{
|
||||
char c ;
|
||||
register int r = sanitize_read((fd_read(selfpipe_fd, &c, 1))) ;
|
||||
return (r <= 0) ? r : (int)c ;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/* ISC license. */
|
||||
|
||||
/* MT-unsafe */
|
||||
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include "sysdeps.h"
|
||||
#include "selfpipe-internal.h"
|
||||
#include "selfpipe.h"
|
||||
|
||||
#ifdef HASSIGNALFD
|
||||
|
||||
#include <sys/signalfd.h>
|
||||
|
||||
int selfpipe_trap (int sig)
|
||||
{
|
||||
sigset_t ss = selfpipe_caught ;
|
||||
sigset_t old ;
|
||||
if (selfpipe_fd < 0) return (errno = EBADF, -1) ;
|
||||
if ((sigaddset(&ss, sig) < 0) || (sigprocmask(SIG_BLOCK, &ss, &old) < 0))
|
||||
return -1 ;
|
||||
if (signalfd(selfpipe_fd, &ss, SFD_NONBLOCK | SFD_CLOEXEC) < 0)
|
||||
{
|
||||
int e = errno ;
|
||||
sigprocmask(SIG_SETMASK, &old, 0) ;
|
||||
errno = e ;
|
||||
return -1 ;
|
||||
}
|
||||
selfpipe_caught = ss ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include "sig.h"
|
||||
|
||||
int selfpipe_trap (int sig)
|
||||
{
|
||||
if (selfpipe_fd < 0) return (errno = EBADF, -1) ;
|
||||
if (sig_catcha(sig, &selfpipe_ssa) < 0) return -1 ;
|
||||
if (sigaddset(&selfpipe_caught, sig) < 0)
|
||||
{
|
||||
int e = errno ;
|
||||
sig_restore(sig) ;
|
||||
errno = e ;
|
||||
return -1 ;
|
||||
}
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,64 +0,0 @@
|
||||
/* ISC license. */
|
||||
|
||||
/* MT-unsafe */
|
||||
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include "sysdeps.h"
|
||||
#include "selfpipe-internal.h"
|
||||
#include "selfpipe.h"
|
||||
|
||||
#ifdef HASSIGNALFD
|
||||
|
||||
#include <sys/signalfd.h>
|
||||
|
||||
int selfpipe_trapset (sigset_t const *set)
|
||||
{
|
||||
sigset_t old ;
|
||||
if (selfpipe_fd < 0) return (errno = EBADF, -1) ;
|
||||
if (sigprocmask(SIG_SETMASK, set, &old) < 0) return -1 ;
|
||||
if (signalfd(selfpipe_fd, set, SFD_NONBLOCK | SFD_CLOEXEC) < 0)
|
||||
{
|
||||
int e = errno ;
|
||||
sigprocmask(SIG_SETMASK, &old, 0) ;
|
||||
errno = e ;
|
||||
return -1 ;
|
||||
}
|
||||
selfpipe_caught = *set ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include "sig.h"
|
||||
#include "nsig.h"
|
||||
|
||||
int selfpipe_trapset (sigset_t const *set)
|
||||
{
|
||||
unsigned int i = 1 ;
|
||||
if (selfpipe_fd < 0) return (errno = EBADF, -1) ;
|
||||
for (; i <= NSIG ; i++)
|
||||
{
|
||||
register int h = sigismember(set, i) ;
|
||||
if (h < 0) continue ;
|
||||
if (h)
|
||||
{
|
||||
if (sig_catcha(i, &selfpipe_ssa) < 0) break ;
|
||||
}
|
||||
else if (sigismember(&selfpipe_caught, i))
|
||||
{
|
||||
if (sig_restore(i) < 0) break ;
|
||||
}
|
||||
}
|
||||
if (i <= NSIG)
|
||||
{
|
||||
int e = errno ;
|
||||
sig_restoreto(set, i) ;
|
||||
errno = e ;
|
||||
return -1 ;
|
||||
}
|
||||
selfpipe_caught = *set ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,54 +0,0 @@
|
||||
/* ISC license. */
|
||||
|
||||
/* MT-unsafe */
|
||||
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include "sysdeps.h"
|
||||
#include "selfpipe-internal.h"
|
||||
#include "selfpipe.h"
|
||||
|
||||
#ifdef HASSIGNALFD
|
||||
|
||||
#include <sys/signalfd.h>
|
||||
|
||||
int selfpipe_untrap (int sig)
|
||||
{
|
||||
sigset_t ss = selfpipe_caught ;
|
||||
sigset_t blah ;
|
||||
register int r = sigismember(&selfpipe_caught, sig) ;
|
||||
if (selfpipe_fd < 0) return (errno = EBADF, -1) ;
|
||||
if (r < 0) return -1 ;
|
||||
if (!r) return (errno = EINVAL, -1) ;
|
||||
if ((sigdelset(&ss, sig) < 0)
|
||||
|| (signalfd(selfpipe_fd, &ss, SFD_NONBLOCK | SFD_CLOEXEC) < 0))
|
||||
return -1 ;
|
||||
sigemptyset(&blah) ;
|
||||
sigaddset(&blah, sig) ;
|
||||
if (sigprocmask(SIG_UNBLOCK, &blah, 0) < 0)
|
||||
{
|
||||
int e = errno ;
|
||||
signalfd(selfpipe_fd, &selfpipe_caught, SFD_NONBLOCK | SFD_CLOEXEC) ;
|
||||
errno = e ;
|
||||
return -1 ;
|
||||
}
|
||||
selfpipe_caught = ss ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include "sig.h"
|
||||
|
||||
int selfpipe_untrap (int sig)
|
||||
{
|
||||
register int r = sigismember(&selfpipe_caught, sig) ;
|
||||
if (selfpipe_fd < 0) return (errno = EBADF, -1) ;
|
||||
if (r < 0) return -1 ;
|
||||
if (!r) return (errno = EINVAL, -1) ;
|
||||
if (sig_restore(sig) < 0) return -1 ;
|
||||
sigdelset(&selfpipe_caught, sig) ;
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,61 +0,0 @@
|
||||
/* ISC license. */
|
||||
|
||||
#ifndef SIG_H
|
||||
#define SIG_H
|
||||
|
||||
#include <signal.h>
|
||||
#include "gccattributes.h"
|
||||
|
||||
extern int sig_alarm gccattr_deprecated ;
|
||||
extern int sig_child gccattr_deprecated ;
|
||||
extern int sig_stop gccattr_deprecated ;
|
||||
extern int sig_cont gccattr_deprecated ;
|
||||
extern int sig_hangup gccattr_deprecated ;
|
||||
extern int sig_int gccattr_deprecated ;
|
||||
extern int sig_kill gccattr_deprecated ;
|
||||
extern int sig_pipe gccattr_deprecated ;
|
||||
extern int sig_term gccattr_deprecated ;
|
||||
extern int sig_usr1 gccattr_deprecated ;
|
||||
extern int sig_usr2 gccattr_deprecated ;
|
||||
extern int sig_quit gccattr_deprecated ;
|
||||
extern int sig_abort gccattr_deprecated ;
|
||||
|
||||
|
||||
typedef void skasighandler_t (int) ;
|
||||
typedef skasighandler_t *skasighandler_t_ref ;
|
||||
|
||||
struct skasigaction
|
||||
{
|
||||
skasighandler_t_ref handler ;
|
||||
unsigned int flags : 2 ;
|
||||
} ;
|
||||
|
||||
#define SKASA_MASKALL 0x01
|
||||
#define SKASA_NOCLDSTOP 0x02
|
||||
|
||||
extern struct skasigaction const SKASIG_DFL ;
|
||||
extern struct skasigaction const SKASIG_IGN ;
|
||||
extern int skasigaction (int, struct skasigaction const *, struct skasigaction *) ;
|
||||
|
||||
#define sig_catcha(sig, ac) skasigaction(sig, (ac), 0)
|
||||
#define sig_restore(sig) skasigaction((sig), &SKASIG_DFL, 0)
|
||||
|
||||
extern void sig_restoreto (sigset_t const *, unsigned int) ;
|
||||
extern int sig_catch (int, skasighandler_t_ref) ;
|
||||
#define sig_ignore(sig) sig_catcha((sig), &SKASIG_IGN)
|
||||
#define sig_uncatch(sig) sig_restore(sig)
|
||||
|
||||
#define SIGSTACKSIZE 16
|
||||
extern int sig_pusha (int, struct skasigaction const *) ;
|
||||
extern int sig_pop (int) ;
|
||||
extern int sig_push (int, skasighandler_t_ref) ;
|
||||
|
||||
extern void sig_block (int) ;
|
||||
extern void sig_blockset (sigset_t const *) ;
|
||||
extern void sig_unblock (int) ;
|
||||
extern void sig_blocknone (void) ;
|
||||
extern void sig_pause (void) ;
|
||||
extern void sig_shield (void) ;
|
||||
extern void sig_unshield (void) ;
|
||||
|
||||
#endif
|
||||
@@ -1,17 +0,0 @@
|
||||
/* ISC license. */
|
||||
|
||||
/* MT-unsafe */
|
||||
|
||||
#include <signal.h>
|
||||
#include "sig.h"
|
||||
|
||||
void sig_restoreto (sigset_t const *set, unsigned int n)
|
||||
{
|
||||
register unsigned int i = 1 ;
|
||||
for (; i <= n ; i++)
|
||||
{
|
||||
register int h = sigismember(set, i) ;
|
||||
if (h < 0) continue ;
|
||||
if (h) sig_restore(i) ;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
/* ISC license. */
|
||||
|
||||
#include <signal.h>
|
||||
#include "sig.h"
|
||||
|
||||
struct skasigaction const SKASIG_DFL = { SIG_DFL, 0 } ;
|
||||
struct skasigaction const SKASIG_IGN = { SIG_IGN, 0 } ;
|
||||
@@ -1,42 +0,0 @@
|
||||
/* ISC license. */
|
||||
|
||||
#include <signal.h>
|
||||
#include "sysdeps.h"
|
||||
#include "sig.h"
|
||||
|
||||
#ifdef HASSIGACTION
|
||||
|
||||
int skasigaction (int sig, struct skasigaction const *new, struct skasigaction *old)
|
||||
{
|
||||
struct sigaction sanew, saold ;
|
||||
if (((new->flags & SKASA_MASKALL) ? sigfillset(&sanew.sa_mask) : sigemptyset(&sanew.sa_mask)) == -1) return -1 ;
|
||||
sanew.sa_handler = new->handler ;
|
||||
sanew.sa_flags = (new->flags & SKASA_NOCLDSTOP) ? SA_NOCLDSTOP : 0 ;
|
||||
if (sigaction(sig, &sanew, &saold) == -1) return -1 ;
|
||||
if (old)
|
||||
{
|
||||
register int r = sigismember(&saold.sa_mask, (sig == SIGTERM) ? SIGPIPE : SIGTERM) ;
|
||||
if (r == -1) return -1 ;
|
||||
old->flags = 0 ;
|
||||
if (r) old->flags |= SKASA_MASKALL ;
|
||||
if (saold.sa_flags & SA_NOCLDSTOP) old->flags |= SKASA_NOCLDSTOP ;
|
||||
old->handler = saold.sa_handler ;
|
||||
}
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int skasigaction (int sig, struct skasigaction const *new, struct skasigaction *old)
|
||||
{
|
||||
skasighandler_t_ref haold = signal(sig, new->handler) ;
|
||||
if (haold == SIG_ERR) return -1 ;
|
||||
if (old)
|
||||
{
|
||||
old->handler = haold ;
|
||||
old->flags = 0 ;
|
||||
}
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,24 +0,0 @@
|
||||
#ifndef SYSDEPS_H
|
||||
#define SYSDEPS_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HAVE_PIPE2_CLOEXEC
|
||||
#define HASPIPE2
|
||||
#else
|
||||
#undef HASPIPE2
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SIGNALFD
|
||||
#define HASSIGNALFD
|
||||
#else
|
||||
#undef HASSIGNALFD
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SIGACTION
|
||||
#define HASSIGACTION
|
||||
#else
|
||||
#undef HASSIGACTION
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,7 +0,0 @@
|
||||
#ifndef UINT64_H
|
||||
#define UINT64_H
|
||||
|
||||
#include <stdint.h>
|
||||
typedef uint64_t uint64;
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user