X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e1082c9fa8763696ea87c75b1435db9d3a2e1d7c..b72aa48cdeca3530ffb6ac5af438835d58bf79d9:/src/unix/utilsunx.cpp diff --git a/src/unix/utilsunx.cpp b/src/unix/utilsunx.cpp index 8d1c888fc7..fbeb877d03 100644 --- a/src/unix/utilsunx.cpp +++ b/src/unix/utilsunx.cpp @@ -155,7 +155,7 @@ int wxKill(long pid, wxSignal sig, wxKillError *rc) int err = kill((pid_t)pid, (int)sig); if ( rc ) { - switch ( err ) + switch ( errno ) { case 0: *rc = wxKILL_OK; @@ -290,6 +290,29 @@ bool wxShell(const wxString& command, wxArrayString& output) return wxExecute(wxMakeShellCommand(command), output); } +// Shutdown or reboot the PC +bool wxShutdown(wxShutdownFlags wFlags) +{ + wxChar level; + switch ( wFlags ) + { + case wxSHUTDOWN_POWEROFF: + level = _T('0'); + break; + + case wxSHUTDOWN_REBOOT: + level = _T('6'); + break; + + default: + wxFAIL_MSG( _T("unknown wxShutdown() flag") ); + return FALSE; + } + + return system(wxString::Format(_T("init %c"), level).mb_str()) == 0; +} + + #if wxUSE_GUI void wxHandleProcessTermination(wxEndProcessData *proc_data) @@ -651,12 +674,14 @@ long wxExecute(wxChar **argv, close(fd); } - if ( flags & wxEXEC_MAKE_GROUP_LEADER ) +#ifndef __VMS + if ( flags & wxEXEC_MAKE_GROUP_LEADER ) { // Set process group to child process' pid. Then killing -pid // of the parent will kill the process and all of its children. setsid(); } +#endif } // redirect stdio, stdout and stderr