Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDick Porter <dick@acm.org>2002-07-04 23:04:20 +0400
committerDick Porter <dick@acm.org>2002-07-04 23:04:20 +0400
commit15e22fd5341c44ce0895689867d2c162ca78fb8c (patch)
tree9c4a8080ab8b3ed9d66db846853072b656107904
parentb0102fd031601e1bbfbaf53d19984c4c8fe2d0d6 (diff)
2002-07-04 Dick Porter <dick@ximian.com>
* daemon.c (process_process_fork): Fix argument handling, due to buggy understanding of g_strsplit() behaviour. svn path=/trunk/mono/; revision=5590
-rw-r--r--mono/io-layer/ChangeLog5
-rw-r--r--mono/io-layer/daemon.c31
-rwxr-xr-xmono/tests/process1.cs35
3 files changed, 68 insertions, 3 deletions
diff --git a/mono/io-layer/ChangeLog b/mono/io-layer/ChangeLog
index 652e4f2b881..f4aa424179e 100644
--- a/mono/io-layer/ChangeLog
+++ b/mono/io-layer/ChangeLog
@@ -1,3 +1,8 @@
+2002-07-04 Dick Porter <dick@ximian.com>
+
+ * daemon.c (process_process_fork): Fix argument handling, due to
+ buggy understanding of g_strsplit() behaviour.
+
2002-07-03 Dick Porter <dick@ximian.com>
* threads.h:
diff --git a/mono/io-layer/daemon.c b/mono/io-layer/daemon.c
index 9e7379dd200..f58282a239a 100644
--- a/mono/io-layer/daemon.c
+++ b/mono/io-layer/daemon.c
@@ -603,7 +603,9 @@ static void process_process_fork (guint32 idx,
process_handle_data->exec_errno=errno;
} else if (pid==0) {
/* child */
- char **argv;
+ char **argv, *full_args;
+ GError *gerr=NULL;
+ gboolean ret;
/* should we detach from the process group?
* We're already running without a controlling
@@ -621,10 +623,33 @@ static void process_process_fork (guint32 idx,
#endif
if(args!=NULL) {
- argv=g_strsplit (args, " \t", 0);
+ full_args=g_strconcat (cmd, " ", args, NULL);
} else {
- argv=g_new0 (char *, 1);
+ full_args=g_strdup (cmd);
}
+ ret=g_shell_parse_argv (full_args, NULL, &argv, &gerr);
+
+ g_free (full_args);
+
+ if(ret==FALSE) {
+ /* FIXME: Could do something with the
+ * GError here
+ */
+ process_handle_data->exec_errno=gerr->code;
+ exit (-1);
+ }
+
+
+#ifdef DEBUG
+ {
+ int i=0;
+ while(argv[i]!=NULL) {
+ g_message ("arg %d: [%s]", i, argv[i]);
+ i++;
+ }
+ }
+#endif
+
/* exec */
execv (cmd, argv);
diff --git a/mono/tests/process1.cs b/mono/tests/process1.cs
new file mode 100755
index 00000000000..af6f364f249
--- /dev/null
+++ b/mono/tests/process1.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Diagnostics;
+using System.Threading;
+
+class Modules {
+ static void Run() {
+ Process proc = new Process();
+ bool ret;
+
+ proc.StartInfo.FileName="wibble";
+ proc.StartInfo.Arguments="arg1 arg2\targ3 \"arg4a arg4b\"";
+ proc.StartInfo.UseShellExecute=false;
+ ret=proc.Start();
+
+ Console.WriteLine("Start returns " + ret);
+ Console.WriteLine("Process is " + proc.ToString());
+ Console.WriteLine("Pid is " + proc.Id);
+ Console.WriteLine("Handle is " + proc.Handle);
+ Console.WriteLine("HandleCount is " + proc.HandleCount);
+
+ Console.WriteLine("Waiting for exit...");
+ proc.WaitForExit();
+ Console.WriteLine("Wait returned");
+ Console.WriteLine("Exit code is " + proc.ExitCode);
+ Console.WriteLine("Process started at " + proc.StartTime);
+ Console.WriteLine("Process ended at " + proc.ExitTime);
+ }
+
+ static void Main() {
+ Run();
+ System.Threading.Thread.Sleep(10000);
+ Run();
+ }
+}
+