// 1. wxPRIORITY_{MIN,DEFAULT,MAX} map to -20, 0 and 19 respectively.
// 2. The mapping is monotonously increasing.
// 3. The mapping is onto the target range.
- int prio = process->GetPriority();
+ int prio = process ? process->GetPriority() : 0;
if ( prio <= 50 )
prio = (2*prio)/5 - 20;
else if ( prio < 55 )
#endif // !__VMS
#if defined(HAVE_SETPRIORITY)
- if ( setpriority(PRIO_PROCESS, 0, prio) != 0 )
+ if ( prio && setpriority(PRIO_PROCESS, 0, prio) != 0 )
{
wxLogSysError(_("Failed to set process priority"));
}
// the trailing newline
static wxString wxGetCommandOutput(const wxString &cmd)
{
- FILE *f = popen(cmd.ToAscii(), "r");
+ // Suppress stderr from the shell to avoid outputting errors if the command
+ // doesn't exist.
+ FILE *f = popen((cmd + " 2>/dev/null").ToAscii(), "r");
if ( !f )
{
- wxLogSysError(wxT("Executing \"%s\" failed"), cmd.c_str());
- return wxEmptyString;
+ // Notice that this doesn't happen simply if the command doesn't exist,
+ // but only in case of some really catastrophic failure inside popen()
+ // so we should really notify the user about this as this is not normal.
+ wxLogSysError(wxT("Executing \"%s\" failed"), cmd);
+ return wxString();
}
wxString s;