#define COMMAND "echo hi"
#define ASYNC_COMMAND "xclock"
#define SHELL_COMMAND "echo hi from shell"
- #define REDIRECT_COMMAND COMMAND "cat -n Makefile"
+ #define REDIRECT_COMMAND "cat -n Makefile"
#elif defined(__WXMSW__)
#define COMMAND "command.com /c echo hi"
#define ASYNC_COMMAND "notepad"
wxPrintf(_T("Testing async wxExecute: "));
fflush(stdout);
- if ( wxExecute(ASYNC_COMMAND) != 0 )
+ int pid = wxExecute(ASYNC_COMMAND);
+ if ( pid != 0 )
+ {
wxPuts(_T("Ok (command launched)."));
+ if ( wxKill(pid) == -1 )
+ wxPuts("ERROR: failed to kill child process.");
+ }
else
wxPuts(_T("ERROR."));
}
else
{
- unsigned count = output.GetCount();
- for ( unsigned n = 0; n < count; n++ )
+ // don't show too much output, MAX_LINES is enough
+ static const unsigned MAX_LINES = 20;
+
+ const unsigned count = output.size();
+ for ( unsigned n = 0;
+ n < (count > MAX_LINES ? MAX_LINES/2 : count);
+ n++ )
{
- wxPrintf("%04u:\t%s\n", n, output[n]);
+ wxPrintf("%04u:\t%s\n", n + 1, output[n]);
+ }
+
+ if ( count > MAX_LINES )
+ {
+ wxPrintf("... skipping %u lines...\n", count - MAX_LINES);
+
+ for ( unsigned n = count - MAX_LINES/2; n < count; n++ )
+ {
+ wxPrintf("%04u:\t%s\n", n + 1, output[n]);
+ }
}
wxPuts(_T("Ok."));