Skip to content
Snippets Groups Projects
Commit 62cb464d authored by deuce's avatar deuce
Browse files

More NetBSD/QNX fixes... also, fixed error where a failed fork() on a

background process wiyld take down the whole BBS.
parent 15d96ff3
No related branches found
No related tags found
No related merge requests found
...@@ -80,9 +80,8 @@ endif ...@@ -80,9 +80,8 @@ endif
include targets.mk # defines all targets include targets.mk # defines all targets
include objects.mk # defines $(OBJS) include objects.mk # defines $(OBJS)
ifeq ($(os),gnu) ifeq ($(os),netbsd)
OBJS += $(ODIR)$(SLASH)sem.$(OFILE) CFLAGS += -D__unix__
CFLAGS += -D_NEED_SEM
endif endif
ifdef USE_DIALOG ifdef USE_DIALOG
......
...@@ -53,7 +53,11 @@ ...@@ -53,7 +53,11 @@
#elif defined(__linux__) #elif defined(__linux__)
#include <pty.h> #include <pty.h>
#elif defined(__QNX__) #elif defined(__QNX__)
#if 0
#include <unix.h> #include <unix.h>
#else
#define NEEDS_FORKPTY
#endif
#endif #endif
#ifdef NEEDS_FORKPTY #ifdef NEEDS_FORKPTY
...@@ -1064,7 +1068,7 @@ static int forkpty(int *amaster, char *name, termios *termp, winsize *winp) ...@@ -1064,7 +1068,7 @@ static int forkpty(int *amaster, char *name, termios *termp, winsize *winp)
if (openpty(&master, &slave, name, termp, winp) == -1) if (openpty(&master, &slave, name, termp, winp) == -1)
return (-1); return (-1);
switch (pid = fork()) { switch (pid = vfork()) {
case -1: case -1:
return (-1); return (-1);
case 0: case 0:
...@@ -1235,7 +1239,7 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir) ...@@ -1235,7 +1239,7 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
} }
if((pid=fork())==-1) { if((pid=vfork())==-1) {
pthread_mutex_unlock(&input_thread_mutex); pthread_mutex_unlock(&input_thread_mutex);
errormsg(WHERE,ERR_EXEC,fullcmdline,0); errormsg(WHERE,ERR_EXEC,fullcmdline,0);
return(-1); return(-1);
...@@ -1292,15 +1296,15 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir) ...@@ -1292,15 +1296,15 @@ int sbbs_t::external(const char* cmdline, long mode, const char* startup_dir)
if(mode&EX_BG) /* background execution, detach child */ if(mode&EX_BG) /* background execution, detach child */
{ {
if(fork()) if(vfork())
exit(0); return(0);
lprintf("Detaching external process pgid=%d",setsid()); lprintf("Detaching external process pgid=%d",setsid());
} }
execvp(argv[0],argv); execvp(argv[0],argv);
sprintf(str,"!ERROR %d executing %s",errno,argv[0]); sprintf(str,"!ERROR %d executing %s",errno,argv[0]);
errorlog(str); errorlog(str);
exit(-1); /* should never get here */ _exit(-1); /* should never get here */
} }
lprintf("Node %d executing external: %s",cfg.node_num,fullcmdline); lprintf("Node %d executing external: %s",cfg.node_num,fullcmdline);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment