Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#11824 closed defect (fixed)

wxExecute returns wrong return code

Reported by: ZenJu Owned by:
Priority: normal Milestone:
Component: wxGTK Version: 2.8.10
Keywords: Cc:
Blocked By: Blocking:
Patch: no



when trying to execute a commandline synchronously, wxExecute always returns a positive return value (that obviously is caused by a character overflow somewhere...)

Tested with this overload in Ubuntu 2.8.10:

long wxExecute(const wxString& command, int sync = wxEXEC_ASYNC, wxProcess *callback = NULL)


long rv = wxExecute(commandline, wxEXEC_SYNC); //execute command
//if commandline starts a program that returns -4, wxExecute returns 252!

Unfortunately my debugger isn't working reliably, so I cannot dive deeper here...

This behavior is really annoying because there is no way to reliably determine an error situation: wxLog messages are not emitted (at least for many invalid commandlines, for a few it actually did emit a useful message) but it returns a positive value like 255, which better be -1 as documented.

Regards, ZenJu

Change History (2)

comment:1 Changed 8 years ago by VZ

  • Resolution set to fixed
  • Status changed from new to closed

(In [63710]) Return exit code as signed integer from wxExecute(wxEXEC_SYNC).

The caller expects the function to return -1 if the child process exited with
-1 error code and not 255 that was returned before. The function is also
documented as returning -1 if the execution fails which wasn't true neither.

Fix this by explicitly handling the exit code as signed.

Closes #11824.

comment:2 Changed 8 years ago by ZenJu

Thank you!


Note: See TracTickets for help on using tickets.