Opened 9 years ago

Closed 9 years ago

#13033 closed defect (wontfix)

wxExecute(app, wxEXEC_SYNC) not working on Mac

Reported by: raanana Owned by:
Priority: normal Milestone:
Component: base Version: 2.8.11
Keywords: mac OSX wxExecute wxEXEC_SYNC Cc:
Blocked By: Blocking:
Patch: no


On Mac OS X 10.5.8, both in 2.8.11/Carbon Unicode, 2.8.12-rc1/Carbon Unicode
wxExecute(,wxEXEC_SYNC) launches Mail but does not wait for it to terminate.

With 2.9 SVN 67181/OSXCocoa & OSXCocoaUnicode, wxExecute(,wxEXEC_SYNC)fails with code 13.

Change History (3)

comment:1 Changed 9 years ago by raanana

Using the code from the sample 'exec', I modified the code of MyFrame::OnSyncExec by hard-coding and adding the line 'wxMessageBox(wxT("Command launched"));' after wxExecute.

with 2.8.11 & 2.8.12_rc2 (carbon), the message 'Command launched' is displayed immediately, without waiting for the command in wxExecute to terminate.

With 2.9 (svn 67218) OSXCocoa, the wxExecute did not execute, generating the message below in the debugger; the 'Command Launched' was displayed.

execvp(/Applications/ failed with error 13!

void MyFrame::OnSyncExec(wxCommandEvent& WXUNUSED(event))
    wxString cmd = (_T("/Applications/"));
    if ( !cmd )

    wxLogStatus( _T("'%s' is running please wait..."), cmd.c_str() );

    int code = wxExecute(cmd, wxEXEC_SYNC);

    wxMessageBox(wxT("Command launched"));

    wxLogStatus(_T("Process '%s' terminated with exit code %d."),
        cmd.c_str(), code);

Compiled with GCC on MAC OSX 10.5.8 using wxDialogBlocks. 


comment:2 Changed 9 years ago by vadz

  • Status changed from new to infoneeded_new

Error 13 is EACCES i.e. "permission denied". I think it's given because you are trying to execute a directory instead of /Applications/ file. And I don't think the former can be expected to work.

Maybe you're looking for wxLaunchDefaultApplication()?

comment:3 Changed 9 years ago by raanana

  • Resolution set to wontfix
  • Status changed from infoneeded_new to closed

After testing it turns out that when calling wxExecute with a directory (eg /Applications/, Mac OSX will resolve the path to the application and launch it, but control is returned immediately. wxEXEC_SYNC is not respected in this case.

When wxExecute is called with the full path (eg /Applications/ then wxEXEC_SYNC is respected.

I would suggest that a comment to that effect is added to the documentation for wxEXEC_SYNC regarding Mac OSX.

Note: See TracTickets for help on using tickets.