*** ./src/Makefile.in.ORIG Wed May 11 16:48:55 2016 --- ./src/Makefile.in Wed May 11 16:49:01 2016 *************** *** 298,305 **** -I$(top_builddir)/include \ @STRIP_END@ ! AM_CXXFLAGS = -Wall ! AM_CFLAGS = -Wall iperf_LDFLAGS = @CFLAGS@ @PTHREAD_CFLAGS@ @WEB100_CFLAGS@ @DEFS@ iperf_SOURCES = \ Client.cpp \ --- 298,305 ---- -I$(top_builddir)/include \ @STRIP_END@ ! AM_CXXFLAGS = ! AM_CFLAGS = iperf_LDFLAGS = @CFLAGS@ @PTHREAD_CFLAGS@ @WEB100_CFLAGS@ @DEFS@ iperf_SOURCES = \ Client.cpp \ *** ./src/main.cpp.ORIG Wed May 11 16:49:28 2016 --- ./src/main.cpp Wed May 11 17:08:08 2016 *************** *** 75,80 **** --- 75,85 ---- #include "service.h" #endif + /* AIX does not have the daemon() system call */ + #ifdef _AIX + #include "daemon.c" + #endif + /* ------------------------------------------------------------------- * prototypes * ------------------------------------------------------------------- */ *************** *** 148,154 **** Mutex_Initialize( &clients_mutex ); // Initialize the thread subsystem ! thread_init( ); // Initialize the interrupt handling thread to 0 sThread = thread_zeroid(); --- 153,159 ---- Mutex_Initialize( &clients_mutex ); // Initialize the thread subsystem ! AIX_thread_init( ); // Initialize the interrupt handling thread to 0 sThread = thread_zeroid(); *** ./src/daemon.c.ORIG Wed May 11 17:04:04 2016 --- ./src/daemon.c Wed May 11 17:03:59 2016 *************** *** 0 **** --- 1,120 ---- + /*---------------------------------------------------------------------------*\ + NAME + daemon.c - replacement daemon(3) function + DESCRIPTION + This source file contains a version of a BSD-style daemon(3) + function, a function to "daemonize" the calling process. This + implementation is based both on the generic daemon logic defined in + the Unix Programmer's FAQ and on the daemon_start() function in + W. Richard Stevens' _Unix_Network_Programming_ book (Prentice-Hall, + 1990). At the time of this writing, the Unix Programmer's FAQ is + located at `http://www.whitefang.com/unix/faq_toc.html' (among + other places). + LICENSE + This source code is released under a BSD-style. See the LICENSE + file for details. + Copyright (c) 2003-2015 Brian M. Clapper, bmc@clapper.org + \*---------------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------------*\ + Includes + \*---------------------------------------------------------------------------*/ + + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + + /*---------------------------------------------------------------------------*\ + Static Routines + \*---------------------------------------------------------------------------*/ + + /* redirect_fds(): redirect stdin, stdout, and stderr to /dev/NULL */ + + static void redirect_fds() + { + (void) close(0); + (void) close(1); + (void) close(2); + + if (open("/dev/null", O_RDWR) != 0) + { + syslog(LOG_ERR, "Unable to open /dev/null: %s", strerror(errno)); + exit(1); + } + + (void) dup(0); + (void) dup(0); + } + + static int do_fork(void) + { + int status = 0; + + switch(fork()) + { + case 0: + /* This is the child that will become the daemon. */ + break; + + case -1: + /* Fork failure. */ + status = -1; + break; + + default: + /* Parent: Exit. */ + _exit(0); + } + + return status; + } + + /*---------------------------------------------------------------------------*\ + Public Routines + \*---------------------------------------------------------------------------*/ + + int daemon(int nochdir, int noclose) + { + int status = 0; + + openlog("daemonize", LOG_PID, LOG_DAEMON); + + /* Fork once to go into the background. */ + if((status = do_fork()) < 0 ) + ; + + /* Create new session */ + else if(setsid() < 0) /* shouldn't fail */ + status = -1; + + /* Fork again to ensure that daemon never reacquires a control terminal. */ + else if((status = do_fork()) < 0 ) + ; + + else + { + /* clear any inherited umask(2) value */ + + umask(0); + + /* We're there. */ + + if(! nochdir) + { + /* Go to a neutral corner. */ + chdir("/"); + } + + if(! noclose) + redirect_fds(); + } + + return status; + } *** ./compat/Thread.c.ORIG Wed May 11 16:47:55 2016 --- ./compat/Thread.c Wed May 11 16:48:16 2016 *************** *** 95,101 **** * Initialize the thread subsystems variables and set the concurrency * level in solaris. * ------------------------------------------------------------------- */ ! void thread_init( ) { Condition_Initialize( &thread_sNum_cond ); #if defined( sun ) /* Solaris apparently doesn't default to timeslicing threads, --- 95,101 ---- * Initialize the thread subsystems variables and set the concurrency * level in solaris. * ------------------------------------------------------------------- */ ! void AIX_thread_init( ) { Condition_Initialize( &thread_sNum_cond ); #if defined( sun ) /* Solaris apparently doesn't default to timeslicing threads, *** ./compat/Makefile.in.ORIG Wed May 11 16:47:28 2016 --- ./compat/Makefile.in Wed May 11 16:47:38 2016 *************** *** 290,297 **** -I$(top_builddir)/include \ @STRIP_END@ ! AM_CXXFLAGS = -Wall ! AM_CFLAGS = -Wall AM_LDFLAGS = -lrt libcompat_a_SOURCES = \ Thread.c \ --- 290,297 ---- -I$(top_builddir)/include \ @STRIP_END@ ! AM_CXXFLAGS = ! AM_CFLAGS = AM_LDFLAGS = -lrt libcompat_a_SOURCES = \ Thread.c \ *** ./include/Thread.h.ORIG Wed May 11 16:48:29 2016 --- ./include/Thread.h Wed May 11 16:48:38 2016 *************** *** 100,106 **** #include "Settings.hpp" // initialize or destroy the thread subsystem ! void thread_init( ); void thread_destroy( ); // start or stop a thread executing --- 100,106 ---- #include "Settings.hpp" // initialize or destroy the thread subsystem ! void AIX_thread_init( ); void thread_destroy( ); // start or stop a thread executing *** ./Makefile.in.ORIG Wed May 11 16:47:04 2016 --- ./Makefile.in Wed May 11 16:47:13 2016 *************** *** 311,318 **** -I$(top_builddir)/include \ @STRIP_END@ ! AM_CXXFLAGS = -Wall ! AM_FLAGS = -Wall all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive --- 311,318 ---- -I$(top_builddir)/include \ @STRIP_END@ ! AM_CXXFLAGS = ! AM_FLAGS = all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive