[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Linphone-developers] [PATCH] linphonecsh: fix up nommu vfork handling
From: |
Mike Frysinger |
Subject: |
[Linphone-developers] [PATCH] linphonecsh: fix up nommu vfork handling |
Date: |
Sat, 1 Jan 2011 17:21:01 -0500 |
The linphonecsh code currently uses the __uClinux__ define to pick
between fork and vfork, but this is a non-standard define. So add
a real configure test for its existence.
While we're here, fix the exit logic as well. You cannot use exit()
with a vfork() child as it'll call deconstructors to run which will
screw up the original parent. Instead, _exit() must be used.
Signed-off-by: Mike Frysinger <address@hidden>
---
configure.ac | 2 +-
console/shell.c | 21 +++++++++++++--------
2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/configure.ac b/configure.ac
index 3d67cba..a2607f2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -115,7 +115,7 @@ AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE",[The name of the
gettext package name])
AC_CHECK_LIB(intl,libintl_gettext)
-AC_CHECK_FUNCS([get_current_dir_name strndup stpcpy] )
+AC_CHECK_FUNCS([fork get_current_dir_name strndup stpcpy])
dnl conditionnal build of console interface.
AC_ARG_ENABLE(console_ui,
diff --git a/console/shell.c b/console/shell.c
index e61a6e5..00e9ad6 100644
--- a/console/shell.c
+++ b/console/shell.c
@@ -19,6 +19,7 @@
*
****************************************************************************/
+#include "config.h"
#include <stdio.h>
#include <stdlib.h>
@@ -128,6 +129,14 @@ static void print_usage(void){
#define MAX_ARGS 10
#ifndef WIN32
+
+#ifdef HAVE_FORK
+# define spawn_fork() fork()
+# define spawn_exit(s) exit(s)
+#else
+# define spawn_fork() vfork()
+# define spawn_exit(s) _exit(s)
+#endif
static void spawn_linphonec(int argc, char *argv[]){
char * args[10];
int i,j;
@@ -142,14 +151,10 @@ static void spawn_linphonec(int argc, char *argv[]){
}
args[j++]=NULL;
-#ifdef __uClinux__
- pid = vfork();
-#else
- pid = fork();
-#endif
+ pid = spawn_fork();
if (pid < 0){
fprintf(stderr,"Could not fork\n");
- exit(-1);
+ spawn_exit(-1);
}
if (pid == 0) {
int fd;
@@ -159,7 +164,7 @@ static void spawn_linphonec(int argc, char *argv[]){
fd = open("/dev/null", O_RDWR);
if (fd==-1){
fprintf(stderr,"Could not open /dev/null\n");
- exit(-1);
+ spawn_exit(-1);
}
dup2(fd, 0);
dup2(fd, 1);
@@ -168,7 +173,7 @@ static void spawn_linphonec(int argc, char *argv[]){
if (execvp("linphonec",args)==-1){
fprintf(stderr,"Fail to spawn linphonec:
%s\n",strerror(errno));
- exit(-1);
+ spawn_exit(-1);
}
}
}
--
1.7.3.1
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Linphone-developers] [PATCH] linphonecsh: fix up nommu vfork handling,
Mike Frysinger <=