Quote Originally Posted by Mario Donick View Post
All music and sound effects are played using an external commandline mp3 player (mpg123). This has several advantages, so I want to keep this.

mpg123 is invoked by using a TProcess which I named "ExtProgram". Here's the code where it crashes ONLY when I start the game from the app bundle (it always works when started from command line!)

Code:
procedure PlayMusic(SoundFile: string);
begin
  StopMusic;
  if blUseExternPlayer = True then
  begin
    ExtProgram.CommandLine := strExternPlayer + ' "' + CONST_DATADIR + 'music/' + Soundfile + '"';

    ExtProgram.Execute;
  end;
end;
I already have printed the complete ExtProgram.CommandLine in a debug file, to ensure that the path is correct -- it is. But still, the program crashes at the ExtProgram.Execute part.

Why, and why only when started as App bundle? Aren't apps allowed to run other programs?


Edit: A bit closer. Usually, I only passed the name of the extern binary (mpg123) to TProcess. Then the game crashed. When I passed the full path to the binary (i.e. /usr/local/bin/mpg123), the game did not crash -- but obviously mpg123 wasn't running either (because I didn't hear anything), although now both the paths to the binary and to the music file to play were full and correct.
You are certainly allowed to run other programs. I do it all the time. However, I never use TProcess, at least not if I need to pass data between the two processes. In such cases i use ptyfork. In other cases I can use fork and exec just like TProcess does.

As you say, with a full path things get more stable. Isn't it the current directory that needs to be known again? And a proper call to chdir would help?