Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting process in new Terminal window on Mac

On Windows I can do CreateProcess(..., CREATE_NEW_CONSOLE, ...) and my child process (which is console app, not GUI) will be launched in a new window. What is the easiest way to emulate this on Mac OS?


1 Answers

open -a Terminal.app $(which program) gets a new terminal running the specified program (assuming you're using bash).

You can use execve() (possible after a fork()) to acheive the same thing in compiled code without knowing any Apple APIs (I imagine there is a proper way to do this...).

Read man open.

Edit: you don't need to specify the path to Terminal.app (the finder can figure that out).


If you have X running, it is even easier: just spawn a new xterm with xterm -e program &.

Read man xterm (which will take longer...).


I'll second Chris about the correct use (or lack thereof) of CLI for ordinary mac programs. In my buisness this is expected but the typical user will be {confused|angry|unhappy}.

like image 116
dmckee --- ex-moderator kitten Avatar answered Dec 11 '25 22:12

dmckee --- ex-moderator kitten