]>
git.saurik.com Git - wxWidgets.git/blob - src/motif/utilsexc.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Execution-related utilities
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation
25 #ifdef __HIDE_FORBIDDEN_NAMES
26 #undefine __HIDE_FORBIDDEN_NAMES
30 /*because 'noshare' is not valid in vax C++*/
38 #if defined(_AIX) || defined(__xlC__)
39 #include <sys/socket.h>
40 #include <sys/select.h>
43 #include <sys/syscall.h>
58 #define wxEXECUTE_WIN_MESSAGE 10000
60 void xt_notify_end_process(XtPointer client
, int *fid
,
63 Bool
*flag
= (Bool
*) client
;
69 long wxExecute(char **argv
, bool sync
, wxProcess
*WXUNUSED(handler
))
75 return 0; // Nothing???
81 /* fork the process */
82 #if defined(sun) || defined(__ultrix) || defined(__bsdi__)
94 /* GUILHEM: Close all fds when sync == 0 */
96 for (int fd
=0;fd
<FD_SETSIZE
;fd
++) {
97 if (proc_link
[1] != fd
)
102 execvp ((const char *)*argv
, (const char **)argv
);
104 execvp (*argv
, argv
);
106 /* GUILHEM: Reopen output stream */
107 // open("/dev/console", O_WRONLY);
110 printf ("%s: command not found\n", *argv
);
113 printf ("wxWindows: could not execute '%s'\n", *argv
);
120 XtAppAddInput((XtAppContext
) wxTheApp
->GetAppContext(), proc_link
[0],
121 (XtPointer
*) XtInputReadMask
,
122 (XtInputCallbackProc
) xt_notify_end_process
,
123 (XtPointer
) &end_process
);
127 XtAppProcessEvent((XtAppContext
) wxTheApp
->GetAppContext(), XtIMAll
);
129 if (WIFEXITED(end_process
) != 0)
130 return WEXITSTATUS(end_process
);
138 long wxExecute (const wxString
& command
, bool sync
)
143 if (command
.IsNull() || command
== "")
144 return 0; // Nothing to do
146 // Run a program the recomended way under X (XView)
150 const char *IFS
= " \t\n";
152 // Build argument vector
153 strncpy (tmp
, (const char*) command
, sizeof (tmp
) / sizeof (char) - 1);
154 tmp
[sizeof (tmp
) / sizeof (char) - 1] = '\0';
155 argv
[argc
++] = strtok (tmp
, IFS
);
156 while ((argv
[argc
++] = strtok (NULL
, IFS
)) != NULL
)
159 return wxExecute(argv
, sync
);