Commit 02062bc5 authored by Karl Chen's avatar Karl Chen

handle fork() failure; setprocess()

svn path=/trunk/boinc/; revision=2055
parent 6146434b
......@@ -5603,3 +5603,12 @@ Karl 2003/08/08
client/*
sched/*
Karl 2003/08/10
- client (unix): handle fork() failure
- client (unix): set application process priority to 19
configure.ac
config.h.in
client/
app.C
......@@ -72,6 +72,9 @@
#include "app.h"
// value for setpriority(2)
static const int PROCESS_IDLE_PRIORITY = 19;
// Goes through an array of strings, and prints each string
//
static int debug_print_argv(char** argv) {
......@@ -362,6 +365,13 @@ int ACTIVE_TASK::start(bool first_time) {
}
pid = fork();
if (pid == -1) {
state = PROCESS_COULDNT_START;
result->active_task_state = PROCESS_COULDNT_START;
gstate.report_result_error(*result, -1, strerror(errno));
msg_printf(wup->project, MSG_ERROR, "fork(): %s", strerror(errno));
return -1;
}
if (pid == 0) {
// from here on we're running in a new process.
// If an error happens, exit nonzero so that the core client
......@@ -390,6 +400,14 @@ int ACTIVE_TASK::start(bool first_time) {
}
scope_messages.printf("ACTIVE_TASK::start(): forked process: pid %d\n", pid);
// set idle process priority
#ifdef HAVE_SETPRIORITY
if (setpriority(PRIO_PROCESS, pid, PROCESS_IDLE_PRIORITY)) {
perror("setpriority");
}
#endif
#endif
state = PROCESS_RUNNING;
result->active_task_state = PROCESS_RUNNING;
......
......@@ -81,6 +81,9 @@
/* Define to 1 if you have the `select' function. */
#undef HAVE_SELECT
/* Define to 1 if you have the `setpriority' function. */
#undef HAVE_SETPRIORITY
/* Define to 1 if you have the <signal.h> header file. */
#undef HAVE_SIGNAL_H
......
......@@ -5655,7 +5655,8 @@ fi
for ac_func in gethostname gettimeofday mkdir select socket strstr uname lockf flock strftime
for ac_func in gethostname gettimeofday mkdir select socket strstr uname lockf flock strftime setpriority
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
......
......@@ -133,7 +133,7 @@ dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_FUNC_VPRINTF
AC_FUNC_WAIT3
AC_CHECK_FUNCS(gethostname gettimeofday mkdir select socket strstr uname lockf flock strftime)
AC_CHECK_FUNCS(gethostname gettimeofday mkdir select socket strstr uname lockf flock strftime setpriority)
dnl Checks for header files.
AC_HEADER_DIRENT
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment