From c7cfc97626d3ab4eb463a57694e8712fbad08dcc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Tue, 20 Jan 1998 22:39:01 +0100
Subject: [PATCH] cpreate_process() Added option "nice".

Rev: src/signal_handler.c:1.26
---
 src/signal_handler.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/src/signal_handler.c b/src/signal_handler.c
index 517e330231..3fa42e4bfa 100644
--- a/src/signal_handler.c
+++ b/src/signal_handler.c
@@ -568,6 +568,23 @@ static HANDLE get_inheritable_handle(struct mapping *optional, char *name)
 
 /*
  * create_process(string *arguments, mapping optional_data);
+ *
+ * optional_data:
+ *
+ *   stdin	object(files.file)
+ *   stdout	object(files.file)
+ *   stderr	object(files.file)
+ *   cwd	string
+ *   env	mapping(string:string)
+ *
+ * only on UNIX:
+ *
+ *   uid	int
+ *   gid	int
+ *   nice	int
+ *
+ * FIXME:
+ *   Support for setresuid() and setresgid().
  */
 void f_create_process(INT32 args)
 {
@@ -814,6 +831,22 @@ void f_create_process(INT32 args)
 	      exit(69);
 
 
+#ifdef HAVE_NICE
+	if ((tmp=simple_mapping_string_lookup(optional, "nice"))) {
+	  if (tmp->type == T_INT) {
+	    int n = nice(0);
+	    int nn = tmp->u.integer;
+
+	    if (nn > (NZERO-1)) {
+	      nn = NZERO-1;
+	    }
+
+	    nice(nn - n);
+	  }
+	}
+#endif /* HAVE_NICE */
+
+
 	if((tmp=simple_mapping_string_lookup(optional, "env")))
 	{
 	  if(tmp->type == T_MAPPING)
-- 
GitLab