Index: trunk/Ohana/src/opihi/pantasks/ControllerOps.c
===================================================================
--- trunk/Ohana/src/opihi/pantasks/ControllerOps.c	(revision 31856)
+++ trunk/Ohana/src/opihi/pantasks/ControllerOps.c	(revision 32632)
@@ -258,4 +258,10 @@
       sprintf (cmd, "job -host %s", job[0].task[0].host);
     }
+  }
+  
+  if (job[0].priority) {
+    char tmp[64];
+    snprintf (tmp, 64, " -nice %d", job[0].priority);
+    strcat (cmd, tmp);
   }
 
Index: trunk/Ohana/src/opihi/pantasks/JobOps.c
===================================================================
--- trunk/Ohana/src/opihi/pantasks/JobOps.c	(revision 31856)
+++ trunk/Ohana/src/opihi/pantasks/JobOps.c	(revision 32632)
@@ -107,4 +107,5 @@
     job[0].mode = JOB_CONTROLLER;
   }
+  job[0].priority = task[0].priority;
 
   /* we need our own copy of task[0].argv argc is the number of valid args, like the usual command line.  we
Index: trunk/Ohana/src/opihi/pantasks/LocalJob.c
===================================================================
--- trunk/Ohana/src/opihi/pantasks/LocalJob.c	(revision 31856)
+++ trunk/Ohana/src/opihi/pantasks/LocalJob.c	(revision 32632)
@@ -161,4 +161,14 @@
   if (VerboseMode()) gprint (GP_ERR, "local job launched\n");
 
+  /* set nice level for the child process -- maybe I should not exit here... */
+  if (job[0].priority) {
+      status = setpriority (PRIO_PROCESS, pid, job[0].priority);
+      if (status == -1) {
+	  gprint (GP_ERR, "error setting priority\n");
+	  perror ("setpriority: ");
+	  exit (2);
+      }
+  }
+
   /* close the other ends of the pipes */
   close (stdout_fd[1]); stdout_fd[1] = 0;
Index: trunk/Ohana/src/opihi/pantasks/Makefile
===================================================================
--- trunk/Ohana/src/opihi/pantasks/Makefile	(revision 31856)
+++ trunk/Ohana/src/opihi/pantasks/Makefile	(revision 32632)
@@ -83,4 +83,5 @@
 $(SRC)/task.$(ARCH).o \
 $(SRC)/task_host.$(ARCH).o \
+$(SRC)/task_nice.$(ARCH).o \
 $(SRC)/task_nmax.$(ARCH).o \
 $(SRC)/task_active.$(ARCH).o \
Index: trunk/Ohana/src/opihi/pantasks/TaskOps.c
===================================================================
--- trunk/Ohana/src/opihi/pantasks/TaskOps.c	(revision 31856)
+++ trunk/Ohana/src/opihi/pantasks/TaskOps.c	(revision 32632)
@@ -487,4 +487,5 @@
 
   NewTask[0].active = TRUE;
+  NewTask[0].priority = 0;
   return (NewTask);
 }
@@ -595,4 +596,5 @@
   if (!strcasecmp (command, "END"))       hash = TASK_END;
   if (!strcasecmp (command, "HOST"))      hash = TASK_HOST;
+  if (!strcasecmp (command, "NICE"))      hash = TASK_NICE;
   if (!strcasecmp (command, "NMAX"))      hash = TASK_NMAX;
   if (!strcasecmp (command, "ACTIVE"))    hash = TASK_ACTIVE;
Index: trunk/Ohana/src/opihi/pantasks/init.c
===================================================================
--- trunk/Ohana/src/opihi/pantasks/init.c	(revision 31856)
+++ trunk/Ohana/src/opihi/pantasks/init.c	(revision 32632)
@@ -4,4 +4,5 @@
 int task            PROTO((int, char **));
 int task_host       PROTO((int, char **));
+int task_nice       PROTO((int, char **));
 int task_nmax       PROTO((int, char **));
 int task_npending   PROTO((int, char **));
@@ -33,4 +34,5 @@
   {1, "halt",       halt,          "halt the scheduler (no job harvesting)"},
   {1, "host",       task_host,     "define host machine for a task"},
+  {1, "nice",       task_nice,     "set nice priority level for a task"},
   {1, "ipptool2book", ipptool2book, "convert queue with ipptool output to book"},
   {1, "kill",       kill_job,      "kill job"},
Index: trunk/Ohana/src/opihi/pantasks/init_server.c
===================================================================
--- trunk/Ohana/src/opihi/pantasks/init_server.c	(revision 31856)
+++ trunk/Ohana/src/opihi/pantasks/init_server.c	(revision 32632)
@@ -4,4 +4,5 @@
 int task            PROTO((int, char **));
 int task_host       PROTO((int, char **));
+int task_nice       PROTO((int, char **));
 int task_nmax       PROTO((int, char **));
 int task_npending   PROTO((int, char **));
@@ -34,4 +35,5 @@
   {1, "delete",     delete_job,    "delete job"},
   {1, "host",       task_host,     "define host machine for a task"},
+  {1, "nice",       task_nice,     "set nice priority level for a task"},
   {1, "ipptool2book", ipptool2book, "convert queue with ipptool output to book"},
   {1, "kill",       kill_job,      "kill job"},
Index: trunk/Ohana/src/opihi/pantasks/pantasks_server.c.in
===================================================================
--- trunk/Ohana/src/opihi/pantasks/pantasks_server.c.in	(revision 31856)
+++ trunk/Ohana/src/opihi/pantasks/pantasks_server.c.in	(revision 32632)
@@ -18,4 +18,5 @@
 int main (int argc, char **argv) {
   
+  char hostname[256], portinfo[256];
   char log_stdout[1024], log_stderr[1024];
   pthread_t JobsAndTasksThread;
@@ -100,6 +101,16 @@
      pass them to the ListenClient thread */
 
+  /* find the defined server hostname */
+  if (VarConfig ("PANTASKS_SERVER", "%s", hostname) == NULL) {
+    gprint (GP_ERR, "pantasks server host undefined\n");
+    exit (31);
+  }
+
+  /* is a port range defined? otherwise use the default */
+  memset (portinfo, 0, 256);
+  VarConfig ("PANTASKS_SERVER_PORT", "%s", portinfo);
+
   /* create the listening socket */
-  InitSocket = InitServerSocket (&Address);
+  InitSocket = InitServerSocket (&Address, hostname, portinfo);
   
   InitPassword ();
Index: trunk/Ohana/src/opihi/pantasks/task.c
===================================================================
--- trunk/Ohana/src/opihi/pantasks/task.c	(revision 31856)
+++ trunk/Ohana/src/opihi/pantasks/task.c	(revision 32632)
@@ -72,4 +72,5 @@
       case TASK_NMAX:
       case TASK_HOST:
+      case TASK_NICE:
       case TASK_EXIT:
       case TASK_EXEC:
Index: trunk/Ohana/src/opihi/pantasks/task_nice.c
===================================================================
--- trunk/Ohana/src/opihi/pantasks/task_nice.c	(revision 32632)
+++ trunk/Ohana/src/opihi/pantasks/task_nice.c	(revision 32632)
@@ -0,0 +1,34 @@
+# include "pantasks.h"
+
+int task_nice (int argc, char **argv) {
+
+  char *endptr = NULL;
+  int priority;
+  Task *task;
+
+  if (argc != 2) {
+    gprint (GP_ERR, "USAGE: nice (priority)\n");
+    return (FALSE);
+  }
+
+  JobTaskLock();
+  task = GetNewTask ();
+  if (task == NULL) {
+    gprint (GP_ERR, "ERROR: not defining or running a task\n");
+    JobTaskUnlock();
+    return (FALSE);
+  }
+
+  priority = strtol (argv[1], &endptr, 10);
+  if (*endptr) goto fail;
+  if (priority < 0) goto fail;
+  if (priority > 20) goto fail;
+
+  task[0].priority = priority;
+  JobTaskUnlock();
+  return (TRUE);
+
+fail:
+    gprint (GP_ERR, "ERROR: nice (priority) -- priority must be an integer 0 to 20\n");
+    return (FALSE);
+}
Index: trunk/Ohana/src/opihi/pantasks/test/nice.sh
===================================================================
--- trunk/Ohana/src/opihi/pantasks/test/nice.sh	(revision 32632)
+++ trunk/Ohana/src/opihi/pantasks/test/nice.sh	(revision 32632)
@@ -0,0 +1,70 @@
+
+# a basic task which just runs 'sleep 10'
+task	       nicetask_local
+  command      sleep 10
+  host         local
+  nice         10
+
+  periods      -poll 0.1
+  periods      -exec 1.0
+  periods      -timeout 20
+  active       true
+  npending 5
+  
+  stdout tmp.txt
+  stderr tmp.txt
+
+  task.exec
+    echo "nicetask_local start"
+  end
+
+  # success
+  task.exit    0
+    echo "nicetask_local stop"
+  end
+
+  # default exit status
+  task.exit    default
+    echo       "failure: exit status: $EXIT"
+  end
+
+  # operation times out?
+  task.exit    timeout
+    echo       "timeout"
+  end
+end
+
+# a basic task which just runs 'sleep 10'
+task	       meantask_local
+  command      sleep 10
+  host         local
+
+  periods      -poll 0.1
+  periods      -exec 1.0
+  periods      -timeout 20
+  active       true
+  npending 5
+  
+  stdout tmp.txt
+  stderr tmp.txt
+
+  task.exec
+    echo "meantask_local start"
+  end
+
+  # success
+  task.exit    0
+    echo "meantask_local stop"
+  end
+
+  # default exit status
+  task.exit    default
+    echo       "failure: exit status: $EXIT"
+  end
+
+  # operation times out?
+  task.exit    timeout
+    echo       "timeout"
+  end
+end
+
Index: trunk/Ohana/src/opihi/pantasks/test/nice_remote.sh
===================================================================
--- trunk/Ohana/src/opihi/pantasks/test/nice_remote.sh	(revision 32632)
+++ trunk/Ohana/src/opihi/pantasks/test/nice_remote.sh	(revision 32632)
@@ -0,0 +1,70 @@
+
+# a basic task which just runs 'sleep 10'
+task	       nicetask_local
+  command      sleep 10
+  host         anyhost
+  nice         10
+
+  periods      -poll 0.1
+  periods      -exec 1.0
+  periods      -timeout 20
+  active       true
+  npending 5
+  
+  stdout tmp.txt
+  stderr tmp.txt
+
+  task.exec
+    echo "nicetask_local start"
+  end
+
+  # success
+  task.exit    0
+    echo "nicetask_local stop"
+  end
+
+  # default exit status
+  task.exit    default
+    echo       "failure: exit status: $EXIT"
+  end
+
+  # operation times out?
+  task.exit    timeout
+    echo       "timeout"
+  end
+end
+
+# a basic task which just runs 'sleep 10'
+task	       meantask_local
+  command      sleep 10
+  host         anyhost
+
+  periods      -poll 0.1
+  periods      -exec 1.0
+  periods      -timeout 20
+  active       true
+  npending 5
+  
+  stdout tmp.txt
+  stderr tmp.txt
+
+  task.exec
+    echo "meantask_local start"
+  end
+
+  # success
+  task.exit    0
+    echo "meantask_local stop"
+  end
+
+  # default exit status
+  task.exit    default
+    echo       "failure: exit status: $EXIT"
+  end
+
+  # operation times out?
+  task.exit    timeout
+    echo       "timeout"
+  end
+end
+
