glib/gspawn-win32.c Implement G_SPAWN_FILE_AND_ARGV_ZERO. (#136792, Bruce

2004-03-10  Tor Lillqvist  <tml@iki.fi>

	* glib/gspawn-win32.c
	* glib/gspawn-win32-helper.c: Implement
	G_SPAWN_FILE_AND_ARGV_ZERO. (#136792, Bruce Hochstetler)

	* tests/spawn-test.c
	* tests/spawn-test-win32-gui.c: Test it.
This commit is contained in:
Tor Lillqvist
2004-03-10 22:59:14 +00:00
committed by Tor Lillqvist
parent 55df929d48
commit f4cb22c78d
10 changed files with 104 additions and 18 deletions

View File

@@ -10,7 +10,14 @@ WinMain (struct HINSTANCE__ *hInstance,
char *lpszCmdLine,
int nCmdShow)
{
if (__argc <= 2)
char buf[100];
if (__argc >= 2 && strcmp (__argv[1], "nop") == 0)
{
sprintf (buf, "spawn-test-win32-gui: argv[0]=\"%s\"", __argv[0]);
MessageBox (NULL, buf, lpszCmdLine, MB_ICONINFORMATION|MB_SYSTEMMODAL);
}
else if (__argc <= 2)
{
MessageBox (NULL, "spawn-test-win32-gui: Will write to stdout",
lpszCmdLine, MB_ICONINFORMATION|MB_SYSTEMMODAL);
@@ -29,7 +36,6 @@ WinMain (struct HINSTANCE__ *hInstance,
int infd = atoi (__argv[2]);
int outfd = atoi (__argv[3]);
int k, n;
char buf[100];
if (infd < 0 || outfd < 0)
{
@@ -87,9 +93,6 @@ WinMain (struct HINSTANCE__ *hInstance,
}
}
MessageBox (NULL, "spawn-test-win32-gui: Sleeping a bit.",
lpszCmdLine, MB_ICONINFORMATION|MB_SYSTEMMODAL);
Sleep (2000);
MessageBox (NULL, "spawn-test-win32-gui: Done, exiting.",

View File

@@ -131,8 +131,9 @@ run_tests (void)
erroutput = NULL;
}
printf ("Starting spawn-test-win32-gui asynchronously (without wait).\n"
"Click on the OK buttons.\n");
printf ("Running spawn-test-win32-gui in various ways. Click on the OK buttons.\n");
printf ("First asynchronously (without wait).\n");
if (!g_spawn_command_line_async ("'.\\spawn-test-win32-gui.exe' 1", &err))
{
@@ -141,8 +142,7 @@ run_tests (void)
exit (1);
}
printf ("Running spawn-test-win32-gui synchronously,\n"
"collecting its output. Click on the OK buttons.\n");
printf ("Now synchronously, collecting its output.\n");
if (!g_spawn_command_line_sync ("'.\\spawn-test-win32-gui.exe' 2",
&output, &erroutput, NULL,
&err))
@@ -174,8 +174,26 @@ run_tests (void)
g_free (erroutput);
}
printf ("Running spawn-test-win32-gui asynchronously again.\n"
"This time talking to it through pipes. Click on the OK buttons.\n");
printf ("Now with G_SPAWN_FILE_AND_ARGV_ZERO.\n");
if (!g_shell_parse_argv ("'.\\spawn-test-win32-gui.exe' this-should-be-argv-zero nop", NULL, &argv, &err))
{
fprintf (stderr, "Error parsing command line? %s\n", err->message);
g_error_free (err);
exit (1);
}
if (!g_spawn_async (NULL, argv, NULL,
G_SPAWN_FILE_AND_ARGV_ZERO,
NULL, NULL, NULL,
&err))
{
fprintf (stderr, "Error: %s\n", err->message);
g_error_free (err);
exit (1);
}
printf ("Now talking to it through pipes.\n");
if (pipe (pipedown) < 0 ||
pipe (pipeup) < 0)