Linux: Use our own signalfd wrapper, rather than libstddjb

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.

(closes #108)
This commit is contained in:
Keegan McAllister
2012-04-12 05:24:50 -04:00
committed by Keith Winstein
parent 93325d3ef0
commit 0eec0b60f0
10 changed files with 180 additions and 46 deletions
+7 -10
View File
@@ -40,10 +40,7 @@
#include <getopt.h>
#include <time.h>
extern "C" {
#include "selfpipe.h"
}
#include "sigfd.h"
#include "completeterminal.h"
#include "swrite.h"
#include "user.h"
@@ -367,14 +364,14 @@ int run_server( const char *desired_ip, const char *desired_port,
void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &network )
{
/* establish fd for shutdown signals */
int signal_fd = selfpipe_init();
int signal_fd = sigfd_init();
if ( signal_fd < 0 ) {
perror( "selfpipe_init" );
perror( "sigfd_init" );
return;
}
fatal_assert( selfpipe_trap( SIGTERM ) == 0 );
fatal_assert( selfpipe_trap( SIGINT ) == 0 );
fatal_assert( sigfd_trap( SIGTERM ) == 0 );
fatal_assert( sigfd_trap( SIGINT ) == 0 );
/* prepare to poll for events */
struct pollfd pollfds[ 3 ];
@@ -516,11 +513,11 @@ void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &network
if ( pollfds[ 2 ].revents & POLLIN ) {
/* shutdown signal */
int signo = selfpipe_read();
int signo = sigfd_read();
if ( signo == 0 ) {
break;
} else if ( signo < 0 ) {
perror( "selfpipe_read" );
perror( "sigfd_read" );
break;
}