mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-07-24 10:57:53 +02:00
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:
committed by
Tor Lillqvist
parent
55df929d48
commit
f4cb22c78d
@@ -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.",
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user