1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: generic Unix implementation of many wx functions
4 // Author: Vadim Zeitlin
6 // Copyright: (c) 1998 Robert Roebling, Vadim Zeitlin
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // ============================================================================
12 // ============================================================================
14 // ----------------------------------------------------------------------------
16 // ----------------------------------------------------------------------------
19 #include "wx/string.h"
26 #include "wx/process.h"
27 #include "wx/thread.h"
29 #include "wx/stream.h"
36 #include "wx/unix/execute.h"
39 // SGI signal.h defines signal handler arguments differently depending on
40 // whether _LANGUAGE_C_PLUS_PLUS is set or not - do set it
41 #if defined(__SGI__) && !defined(_LANGUAGE_C_PLUS_PLUS)
42 #define _LANGUAGE_C_PLUS_PLUS 1
49 #include <sys/types.h>
56 #include <fcntl.h> // for O_WRONLY and friends
57 #include <time.h> // nanosleep() and/or usleep()
58 #include <ctype.h> // isspace()
59 #include <sys/time.h> // needed for FD_SETSIZE
62 #include <sys/utsname.h> // for uname()
65 // ----------------------------------------------------------------------------
66 // conditional compilation
67 // ----------------------------------------------------------------------------
69 // many versions of Unices have this function, but it is not defined in system
70 // headers - please add your system here if it is the case for your OS.
71 // SunOS < 5.6 (i.e. Solaris < 2.6) and DG-UX are like this.
72 #if !defined(HAVE_USLEEP) && \
73 (defined(__SUN__) && !defined(__SunOs_5_6) && \
74 !defined(__SunOs_5_7) && !defined(__SUNPRO_CC)) || \
75 defined(__osf__) || defined(__EMX__)
79 int usleep(unsigned int usec
);
82 /* I copied this from the XFree86 diffs. AV. */
83 #define INCL_DOSPROCESS
85 inline void usleep(unsigned long delay
)
87 DosSleep(delay
? (delay
/1000l) : 1l);
90 void usleep(unsigned long usec
);
92 #endif // Sun/EMX/Something else
96 #endif // Unices without usleep()
98 // ============================================================================
100 // ============================================================================
102 // ----------------------------------------------------------------------------
104 // ----------------------------------------------------------------------------
106 void wxSleep(int nSecs
)
111 void wxUsleep(unsigned long milliseconds
)
113 #if defined(HAVE_NANOSLEEP)
115 tmReq
.tv_sec
= (time_t)(milliseconds
/ 1000);
116 tmReq
.tv_nsec
= (milliseconds
% 1000) * 1000 * 1000;
118 // we're not interested in remaining time nor in return value
119 (void)nanosleep(&tmReq
, (timespec
*)NULL
);
120 #elif defined(HAVE_USLEEP)
121 // uncomment this if you feel brave or if you are sure that your version
122 // of Solaris has a safe usleep() function but please notice that usleep()
123 // is known to lead to crashes in MT programs in Solaris 2.[67] and is not
124 // documented as MT-Safe
125 #if defined(__SUN__) && wxUSE_THREADS
126 #error "usleep() cannot be used in MT programs under Solaris."
129 usleep(milliseconds
* 1000); // usleep(3) wants microseconds
130 #elif defined(HAVE_SLEEP)
131 // under BeOS sleep() takes seconds (what about other platforms, if any?)
132 sleep(milliseconds
* 1000);
133 #else // !sleep function
134 #error "usleep() or nanosleep() function required for wxUsleep"
135 #endif // sleep function
138 // ----------------------------------------------------------------------------
139 // process management
140 // ----------------------------------------------------------------------------
142 int wxKill(long pid
, wxSignal sig
, wxKillError
*rc
)
144 int err
= kill((pid_t
)pid
, (int)sig
);
154 *rc
= wxKILL_BAD_SIGNAL
;
158 *rc
= wxKILL_ACCESS_DENIED
;
162 *rc
= wxKILL_NO_PROCESS
;
166 // this goes against Unix98 docs so log it
167 wxLogDebug(_T("unexpected kill(2) return value %d"), err
);
177 #define WXEXECUTE_NARGS 127
179 long wxExecute( const wxString
& command
, bool sync
, wxProcess
*process
)
181 wxCHECK_MSG( !command
.IsEmpty(), 0, wxT("can't exec empty command") );
184 wxChar
*argv
[WXEXECUTE_NARGS
];
186 const wxChar
*cptr
= command
.c_str();
187 wxChar quotechar
= wxT('\0'); // is arg quoted?
188 bool escaped
= FALSE
;
190 // split the command line in arguments
194 quotechar
= wxT('\0');
196 // eat leading whitespace:
197 while ( wxIsspace(*cptr
) )
200 if ( *cptr
== wxT('\'') || *cptr
== wxT('"') )
205 if ( *cptr
== wxT('\\') && ! escaped
)
212 // all other characters:
216 // have we reached the end of the argument?
217 if ( (*cptr
== quotechar
&& ! escaped
)
218 || (quotechar
== wxT('\0') && wxIsspace(*cptr
))
219 || *cptr
== wxT('\0') )
221 wxASSERT_MSG( argc
< WXEXECUTE_NARGS
,
222 wxT("too many arguments in wxExecute") );
224 argv
[argc
] = new wxChar
[argument
.length() + 1];
225 wxStrcpy(argv
[argc
], argument
.c_str());
228 // if not at end of buffer, swallow last character:
232 break; // done with this one, start over
238 // do execute the command
239 long lRc
= wxExecute(argv
, sync
, process
);
244 delete [] argv
[argc
++];
249 // ----------------------------------------------------------------------------
251 // ----------------------------------------------------------------------------
253 static wxString
wxMakeShellCommand(const wxString
& command
)
258 // just an interactive shell
263 // execute command in a shell
264 cmd
<< _T("/bin/sh -c '") << command
<< _T('\'');
270 bool wxShell(const wxString
& command
)
272 return wxExecute(wxMakeShellCommand(command
), TRUE
/* sync */) == 0;
275 bool wxShell(const wxString
& command
, wxArrayString
& output
)
277 wxCHECK_MSG( !!command
, FALSE
, _T("can't exec shell non interactively") );
279 return wxExecute(wxMakeShellCommand(command
), output
);
284 void wxHandleProcessTermination(wxEndProcessData
*proc_data
)
286 int pid
= (proc_data
->pid
> 0) ? proc_data
->pid
: -(proc_data
->pid
);
288 // waitpid is POSIX so should be available everywhere, however on older
289 // systems wait() might be used instead in a loop (until the right pid
294 // wait for child termination and if waitpid() was interrupted, try again
297 rc
= waitpid(pid
, &status
, 0);
299 while ( rc
== -1 && errno
== EINTR
);
302 if( rc
== -1 || ! (WIFEXITED(status
) || WIFSIGNALED(status
)) )
304 // wxLogSysError(_("Waiting for subprocess termination failed"));
305 /* AFAIK, this can only happen if something went wrong within
306 wxGTK, i.e. due to a race condition or some serious bug.
307 After having fixed the order of statements in
308 GTK_EndProcessDetector(). (KB)
310 JACS adds -- I have other code that kills a process recursively
311 and calls waitpid; so this function then generates an error.
312 I've commented out the wxLogSysError and the 'else' so that
313 termination is always done properly.
318 // notify user about termination if required
319 if (proc_data
->process
)
321 proc_data
->process
->OnTerminate(proc_data
->pid
,
322 WEXITSTATUS(status
));
325 if ( proc_data
->pid
> 0 )
331 // wxExecute() will know about it
332 proc_data
->exitcode
= status
;
341 // ----------------------------------------------------------------------------
342 // wxStream classes to support IO redirection in wxExecute
343 // ----------------------------------------------------------------------------
347 class wxProcessFileInputStream
: public wxInputStream
350 wxProcessFileInputStream(int fd
) { m_fd
= fd
; }
351 ~wxProcessFileInputStream() { close(m_fd
); }
353 virtual bool Eof() const;
356 size_t OnSysRead(void *buffer
, size_t bufsize
);
362 class wxProcessFileOutputStream
: public wxOutputStream
365 wxProcessFileOutputStream(int fd
) { m_fd
= fd
; }
366 ~wxProcessFileOutputStream() { close(m_fd
); }
369 size_t OnSysWrite(const void *buffer
, size_t bufsize
);
375 bool wxProcessFileInputStream::Eof() const
377 if ( m_lasterror
== wxSTREAM_EOF
)
380 // check if there is any input available
387 FD_SET(m_fd
, &readfds
);
388 switch ( select(m_fd
+ 1, &readfds
, NULL
, NULL
, &tv
) )
391 wxLogSysError(_("Impossible to get child process input"));
398 wxFAIL_MSG(_T("unexpected select() return value"));
399 // still fall through
402 // input available: check if there is any
403 return wxInputStream::Eof();
407 size_t wxProcessFileInputStream::OnSysRead(void *buffer
, size_t bufsize
)
409 int ret
= read(m_fd
, buffer
, bufsize
);
412 m_lasterror
= wxSTREAM_EOF
;
414 else if ( ret
== -1 )
416 m_lasterror
= wxSTREAM_READ_ERROR
;
421 m_lasterror
= wxSTREAM_NOERROR
;
427 size_t wxProcessFileOutputStream::OnSysWrite(const void *buffer
, size_t bufsize
)
429 int ret
= write(m_fd
, buffer
, bufsize
);
432 m_lasterror
= wxSTREAM_WRITE_ERROR
;
437 m_lasterror
= wxSTREAM_NOERROR
;
443 #endif // wxUSE_STREAMS
445 long wxExecute(wxChar
**argv
,
449 // for the sync execution, we return -1 to indicate failure, but for async
450 // case we return 0 which is never a valid PID
452 // we define this as a macro, not a variable, to avoid compiler warnings
453 // about "ERROR_RETURN_CODE value may be clobbered by fork()"
454 #define ERROR_RETURN_CODE ((sync) ? -1 : 0)
456 wxCHECK_MSG( *argv
, ERROR_RETURN_CODE
, wxT("can't exec empty command") );
460 char *mb_argv
[WXEXECUTE_NARGS
];
462 while (argv
[mb_argc
])
464 wxWX2MBbuf mb_arg
= wxConvertWX2MB(argv
[mb_argc
]);
465 mb_argv
[mb_argc
] = strdup(mb_arg
);
468 mb_argv
[mb_argc
] = (char *) NULL
;
470 // this macro will free memory we used above
471 #define ARGS_CLEANUP \
472 for ( mb_argc = 0; mb_argv[mb_argc]; mb_argc++ ) \
473 free(mb_argv[mb_argc])
475 // no need for cleanup
478 wxChar
**mb_argv
= argv
;
479 #endif // Unicode/ANSI
483 int end_proc_detect
[2];
484 if ( pipe(end_proc_detect
) == -1 )
486 wxLogSysError( _("Pipe creation failed") );
487 wxLogError( _("Failed to execute '%s'\n"), *argv
);
491 return ERROR_RETURN_CODE
;
495 // pipes for inter process communication
496 int pipeIn
[2], // stdin
497 pipeOut
[2], // stdout
498 pipeErr
[2]; // stderr
500 pipeIn
[0] = pipeIn
[1] =
501 pipeOut
[0] = pipeOut
[1] =
502 pipeErr
[0] = pipeErr
[1] = -1;
504 if ( process
&& process
->IsRedirected() )
506 if ( pipe(pipeIn
) == -1 || pipe(pipeOut
) == -1 || pipe(pipeErr
) == -1 )
509 // free previously allocated resources
510 close(end_proc_detect
[0]);
511 close(end_proc_detect
[1]);
514 wxLogSysError( _("Pipe creation failed") );
515 wxLogError( _("Failed to execute '%s'\n"), *argv
);
519 return ERROR_RETURN_CODE
;
530 if ( pid
== -1 ) // error?
533 close(end_proc_detect
[0]);
534 close(end_proc_detect
[1]);
543 wxLogSysError( _("Fork failed") );
547 return ERROR_RETURN_CODE
;
549 else if ( pid
== 0 ) // we're in child
552 close(end_proc_detect
[0]); // close reading side
555 // These lines close the open file descriptors to to avoid any
556 // input/output which might block the process or irritate the user. If
557 // one wants proper IO for the subprocess, the right thing to do is to
558 // start an xterm executing it.
561 for ( int fd
= 0; fd
< FD_SETSIZE
; fd
++ )
563 if ( fd
== pipeIn
[0] || fd
== pipeOut
[1] || fd
== pipeErr
[1]
565 || fd
== end_proc_detect
[1]
569 // don't close this one, we still need it
573 // leave stderr opened too, it won't do any hurm
574 if ( fd
!= STDERR_FILENO
)
579 // redirect stdio, stdout and stderr
580 if ( pipeIn
[0] != -1 )
582 if ( dup2(pipeIn
[0], STDIN_FILENO
) == -1 ||
583 dup2(pipeOut
[1], STDOUT_FILENO
) == -1 ||
584 dup2(pipeErr
[1], STDERR_FILENO
) == -1 )
586 wxLogSysError(_("Failed to redirect child process input/output"));
594 execvp (*mb_argv
, mb_argv
);
596 // there is no return after successful exec()
599 else // we're in parent
603 // pipe initialization: construction of the wxStreams
604 if ( process
&& process
->IsRedirected() )
607 // These two streams are relative to this process.
608 wxOutputStream
*outStream
= new wxProcessFileOutputStream(pipeIn
[1]);
609 wxInputStream
*inStream
= new wxProcessFileInputStream(pipeOut
[0]);
610 wxInputStream
*errStream
= new wxProcessFileInputStream(pipeErr
[0]);
612 process
->SetPipeStreams(inStream
, outStream
, errStream
);
613 #endif // wxUSE_STREAMS
615 close(pipeIn
[0]); // close reading side
616 close(pipeOut
[1]); // close writing side
617 close(pipeErr
[1]); // close writing side
620 #if wxUSE_GUI && !defined(__WXMICROWIN__)
621 wxEndProcessData
*data
= new wxEndProcessData
;
625 // we may have process for capturing the program output, but it's
626 // not used in wxEndProcessData in the case of sync execution
627 data
->process
= NULL
;
629 // sync execution: indicate it by negating the pid
631 data
->tag
= wxAddProcessCallback(data
, end_proc_detect
[0]);
633 close(end_proc_detect
[1]); // close writing side
638 // it will be set to 0 from GTK_EndProcessDetector
639 while (data
->pid
!= 0)
642 int exitcode
= data
->exitcode
;
648 else // async execution
650 // async execution, nothing special to do - caller will be
651 // notified about the process termination if process != NULL, data
652 // will be deleted in GTK_EndProcessDetector
653 data
->process
= process
;
655 data
->tag
= wxAddProcessCallback(data
, end_proc_detect
[0]);
657 close(end_proc_detect
[1]); // close writing side
662 wxASSERT_MSG( sync
, wxT("async execution not supported yet") );
665 if ( waitpid(pid
, &exitcode
, 0) == -1 || !WIFEXITED(exitcode
) )
667 wxLogSysError(_("Waiting for subprocess termination failed"));
674 // VMS does not recognise exit as a return and complains about
676 // I think VMS is wrong in this
682 #undef ERROR_RETURN_CODE
685 // ----------------------------------------------------------------------------
686 // file and directory functions
687 // ----------------------------------------------------------------------------
689 const wxChar
* wxGetHomeDir( wxString
*home
)
691 *home
= wxGetUserHome( wxString() );
693 if ( home
->IsEmpty() )
697 if ( tmp
.Last() != wxT(']'))
698 if ( tmp
.Last() != wxT('/')) *home
<< wxT('/');
700 return home
->c_str();
704 const wxMB2WXbuf
wxGetUserHome( const wxString
&user
)
705 #else // just for binary compatibility -- there is no 'const' here
706 char *wxGetUserHome( const wxString
&user
)
709 struct passwd
*who
= (struct passwd
*) NULL
;
715 if ((ptr
= wxGetenv(wxT("HOME"))) != NULL
)
719 if ((ptr
= wxGetenv(wxT("USER"))) != NULL
|| (ptr
= wxGetenv(wxT("LOGNAME"))) != NULL
)
721 who
= getpwnam(wxConvertWX2MB(ptr
));
724 // We now make sure the the user exists!
727 who
= getpwuid(getuid());
732 who
= getpwnam (user
.mb_str());
735 return wxConvertMB2WX(who
? who
->pw_dir
: 0);
738 // ----------------------------------------------------------------------------
739 // network and user id routines
740 // ----------------------------------------------------------------------------
742 // retrieve either the hostname or FQDN depending on platform (caller must
743 // check whether it's one or the other, this is why this function is for
745 static bool wxGetHostNameInternal(wxChar
*buf
, int sz
)
747 wxCHECK_MSG( buf
, FALSE
, wxT("NULL pointer in wxGetHostNameInternal") );
751 // we're using uname() which is POSIX instead of less standard sysinfo()
752 #if defined(HAVE_UNAME)
754 bool ok
= uname(&uts
) != -1;
757 wxStrncpy(buf
, wxConvertMB2WX(uts
.nodename
), sz
- 1);
760 #elif defined(HAVE_GETHOSTNAME)
761 bool ok
= gethostname(buf
, sz
) != -1;
762 #else // no uname, no gethostname
763 wxFAIL_MSG(wxT("don't know host name for this machine"));
766 #endif // uname/gethostname
770 wxLogSysError(_("Cannot get the hostname"));
776 bool wxGetHostName(wxChar
*buf
, int sz
)
778 bool ok
= wxGetHostNameInternal(buf
, sz
);
782 // BSD systems return the FQDN, we only want the hostname, so extract
783 // it (we consider that dots are domain separators)
784 wxChar
*dot
= wxStrchr(buf
, wxT('.'));
795 bool wxGetFullHostName(wxChar
*buf
, int sz
)
797 bool ok
= wxGetHostNameInternal(buf
, sz
);
801 if ( !wxStrchr(buf
, wxT('.')) )
803 struct hostent
*host
= gethostbyname(wxConvertWX2MB(buf
));
806 wxLogSysError(_("Cannot get the official hostname"));
812 // the canonical name
813 wxStrncpy(buf
, wxConvertMB2WX(host
->h_name
), sz
);
816 //else: it's already a FQDN (BSD behaves this way)
822 bool wxGetUserId(wxChar
*buf
, int sz
)
827 if ((who
= getpwuid(getuid ())) != NULL
)
829 wxStrncpy (buf
, wxConvertMB2WX(who
->pw_name
), sz
- 1);
836 bool wxGetUserName(wxChar
*buf
, int sz
)
841 if ((who
= getpwuid (getuid ())) != NULL
)
843 // pw_gecos field in struct passwd is not standard
845 char *comma
= strchr(who
->pw_gecos
, ',');
847 *comma
= '\0'; // cut off non-name comment fields
848 wxStrncpy (buf
, wxConvertMB2WX(who
->pw_gecos
), sz
- 1);
849 #else // !HAVE_PW_GECOS
850 wxStrncpy (buf
, wxConvertMB2WX(who
->pw_name
), sz
- 1);
851 #endif // HAVE_PW_GECOS/!HAVE_PW_GECOS
858 wxString
wxGetOsDescription()
860 #ifndef WXWIN_OS_DESCRIPTION
861 #error WXWIN_OS_DESCRIPTION should be defined in config.h by configure
863 return WXWIN_OS_DESCRIPTION
;
867 // this function returns the GUI toolkit version in GUI programs, but OS
868 // version in non-GUI ones
871 int wxGetOsVersion(int *majorVsn
, int *minorVsn
)
876 if ( sscanf(WXWIN_OS_DESCRIPTION
, "%s %d.%d", name
, &major
, &minor
) != 3 )
878 // unreckognized uname string format
892 long wxGetFreeMemory()
894 #if defined(__LINUX__)
895 // get it from /proc/meminfo
896 FILE *fp
= fopen("/proc/meminfo", "r");
902 if ( fgets(buf
, WXSIZEOF(buf
), fp
) && fgets(buf
, WXSIZEOF(buf
), fp
) )
904 long memTotal
, memUsed
;
905 sscanf(buf
, "Mem: %ld %ld %ld", &memTotal
, &memUsed
, &memFree
);
912 #elif defined(__SUN__) && defined(_SC_AVPHYS_PAGES)
913 return sysconf(_SC_AVPHYS_PAGES
)*sysconf(_SC_PAGESIZE
);
914 //#elif defined(__FREEBSD__) -- might use sysctl() to find it out, probably
921 bool wxGetDiskSpace(const wxString
& path
, wxLongLong
*pTotal
, wxLongLong
*pFree
)
926 if ( statfs(path
, &fs
) != 0 )
928 wxLogSysError("Failed to get file system statistics");
935 *pTotal
= wxLongLong(fs
.f_blocks
) * fs
.f_bsize
;
940 *pFree
= wxLongLong(fs
.f_bavail
) * fs
.f_bsize
;
944 #endif // HAVE_STATFS
949 // ----------------------------------------------------------------------------
951 // ----------------------------------------------------------------------------
953 bool wxGetEnv(const wxString
& var
, wxString
*value
)
955 // wxGetenv is defined as getenv()
956 wxChar
*p
= wxGetenv(var
);
968 bool wxSetEnv(const wxString
& variable
, const wxChar
*value
)
970 #if defined(HAVE_SETENV)
971 return setenv(variable
.mb_str(), value
? wxString(value
).mb_str().data()
972 : NULL
, 1 /* overwrite */) == 0;
973 #elif defined(HAVE_PUTENV)
974 wxString s
= variable
;
976 s
<< _T('=') << value
;
979 const char *p
= s
.mb_str();
981 // the string will be free()d by libc
982 char *buf
= (char *)malloc(strlen(p
) + 1);
985 return putenv(buf
) == 0;
986 #else // no way to set an env var
991 // ----------------------------------------------------------------------------
993 // ----------------------------------------------------------------------------
995 #if wxUSE_ON_FATAL_EXCEPTION
999 static void wxFatalSignalHandler(wxTYPE_SA_HANDLER
)
1003 // give the user a chance to do something special about this
1004 wxTheApp
->OnFatalException();
1010 bool wxHandleFatalExceptions(bool doit
)
1013 static bool s_savedHandlers
= FALSE
;
1014 static struct sigaction s_handlerFPE
,
1020 if ( doit
&& !s_savedHandlers
)
1022 // install the signal handler
1023 struct sigaction act
;
1025 // some systems extend it with non std fields, so zero everything
1026 memset(&act
, 0, sizeof(act
));
1028 act
.sa_handler
= wxFatalSignalHandler
;
1029 sigemptyset(&act
.sa_mask
);
1032 ok
&= sigaction(SIGFPE
, &act
, &s_handlerFPE
) == 0;
1033 ok
&= sigaction(SIGILL
, &act
, &s_handlerILL
) == 0;
1034 ok
&= sigaction(SIGBUS
, &act
, &s_handlerBUS
) == 0;
1035 ok
&= sigaction(SIGSEGV
, &act
, &s_handlerSEGV
) == 0;
1038 wxLogDebug(_T("Failed to install our signal handler."));
1041 s_savedHandlers
= TRUE
;
1043 else if ( s_savedHandlers
)
1045 // uninstall the signal handler
1046 ok
&= sigaction(SIGFPE
, &s_handlerFPE
, NULL
) == 0;
1047 ok
&= sigaction(SIGILL
, &s_handlerILL
, NULL
) == 0;
1048 ok
&= sigaction(SIGBUS
, &s_handlerBUS
, NULL
) == 0;
1049 ok
&= sigaction(SIGSEGV
, &s_handlerSEGV
, NULL
) == 0;
1052 wxLogDebug(_T("Failed to uninstall our signal handler."));
1055 s_savedHandlers
= FALSE
;
1057 //else: nothing to do
1062 #endif // wxUSE_ON_FATAL_EXCEPTION
1064 // ----------------------------------------------------------------------------
1065 // error and debug output routines (deprecated, use wxLog)
1066 // ----------------------------------------------------------------------------
1068 void wxDebugMsg( const char *format
, ... )
1071 va_start( ap
, format
);
1072 vfprintf( stderr
, format
, ap
);
1077 void wxError( const wxString
&msg
, const wxString
&title
)
1079 wxFprintf( stderr
, _("Error ") );
1080 if (!title
.IsNull()) wxFprintf( stderr
, wxT("%s "), WXSTRINGCAST(title
) );
1081 if (!msg
.IsNull()) wxFprintf( stderr
, wxT(": %s"), WXSTRINGCAST(msg
) );
1082 wxFprintf( stderr
, wxT(".\n") );
1085 void wxFatalError( const wxString
&msg
, const wxString
&title
)
1087 wxFprintf( stderr
, _("Error ") );
1088 if (!title
.IsNull()) wxFprintf( stderr
, wxT("%s "), WXSTRINGCAST(title
) );
1089 if (!msg
.IsNull()) wxFprintf( stderr
, wxT(": %s"), WXSTRINGCAST(msg
) );
1090 wxFprintf( stderr
, wxT(".\n") );
1091 exit(3); // the same exit code as for abort()