How-To open multiple instances of an application with OS X

download mp3
It happened to me to have the need to run at the same time the Skype application in Mac OS X being logged with two different accounts, this was needed to test the messaging and file sharing capabilities or simply to be able to receive calls on two different accounts or registered numbers at the same time.

That practice is not actually permitted with the current version of Skype for Mac OS X (Skype Version 2.8.0.251) so I had to find a DIY solution.

At the beginning I tried to copy the application bundle and launch it, wishing that the system was recognising this as a distinct application but unfortunately that didn’t work and Mac OS X was complaining that the application was already running and it could not open a second instance of it (due to a conflict of resources).

I then started wondering why in GNU/Linux (that is a not-so-far cousin of Mac OS X UNIX subsystem), wasn’t that difficult to launch from command-line a second instance of an application, so it came to my mind the ‘open’ command that sometimes I use with AppleScript to launch some applications.

Reading the manual of ‘open’ I discovered these two ‘magical’ options:

The ‘-n’ option, that guarantees the opening of a new instance of the application;

The ‘-a’ option, that permits to specify the name of an application without the bundle extension ‘.app’ and without specifying the absolute path of the application (that in this case would generally be ‘/Applications/Skype.app’;

I ended up with this ‘best solution’ to open a second (or further) copy of an application with Mac OS X using the given CLI command ‘open’ as follows:

# open -na <application_name>

Comments

About marcomc

Marco M.C. is a System Administrator with 10 years of professional experience in ICT. He has deep knowledge of Mac OS X, Windows, and GNU/Linux.
His hobbies vary from DIY, Traveling, learning foreign languages and especially he love to cook and experiment with food from all around the world.

As well I had sometimes the necessity to log in the same blog or website with two different users (with two different access level) to verify the differences of behaviour according to the different logged account.

Opening a second tab of the same browser does not suite the task because the credential are stored in the environment variables of the browser instance, so the additional tab will forward or overwrite the credentials and will not allow a double login with different credentials to the same website or blog.

Somebody would suggest to run a different browser such Opera, Mozilla or Shiira, this is actually a good solution, but is not suitable for the 100% of the situations because what we could be testing is behaviour of a javascript feature or plugin dedicated to Safari or another specific browser that is replicable only with a second running copy of the same browser at the same release version.

using the ‘open’ command result in this case the most suitable and elegant practice:

Actually, it would be interesting to create an applescript App hat would permit to drag & drop an application icon on it and automatically launch a second instance of the application.
I did not have time to experiment, if anybody did it, please post a link 😀

The limitation of a single instance of Skype is due to a Skype restriction in this case, but
according to the book Skype Hacks by Andrew Sheppard it is possible to run multiple instances of Skype under the same user session in Mac OS X (and in Windows and Linux as well), as reported in page 102 and 123 of the book.
Unfortunately I’m not able to find the part of the book, if is present, where it explains how to do it.
there could be a command-line parameter but there is not an explanatory list of all the available Skype launch parameters.

Yes, that’s a common workaround, but my aim was to open multiple instances of Skype with the same user account to manage multiple Skype account or telephone numbers. It is anyway a working solution for most of the situations although I do not consider it elegant.

The fact is that in a corporate environment where the users are restricted to the domain users managed by the Sys Admin, the common user has not the option to create new users or to escalate its privileges to another user.
As well, the Sys Admin generally doesn’t like to create an account just to run a specific software because it could be a security weakness as it won’t be an account whose password change frequently, and especially the ‘real’ users will tend to exchange the credentials of this kind of users. This could be a subject for another thread :D.

this did not work for me. nothing at all happens. no error messages, no nothing. i tried it from the initial user prompt, then cd’d to the to root and tried again, then cd’d to the applications folder and tried again. nada.

any ideas? I’d really appreciate it, i have been googling for a solution that doesnt require a second spoof user account, but drawing blanks! a second user account just uses to much hdd space to be workable for the *sole* purpose of running two instances of skype.

Unfortunately I still didn’t find a working solution.
I tried to isolate the files ‘touched’ by a launching Skype instance with the PackageMaker snapshot feature, but non of the files found were semaphores or locks.
Most probably the application verify if there is already some process named Skype and if so it refuses to launch.
What I suggest to do is to experiment a way to launch each instance of Skype in a ‘stealth’ mode so it doesn’t appear in the processes list (‘ps’, ‘top’ or ‘Activity Monitor’).
I don’t know if this is possible, I’m having a fast investigation but any hint is welcome.

Please note that effectively having 2 instances of Skype running would lead in resource conflict as the system would not know to which instance it should let use the camera, mic and audio output.

Using sudo (Super User Do) to run a user process is a terrible idea. This will run Skype as the ‘root’ (Administrator) user.

This violates the common principle of least privilege… in short running a program with the least permissions necessary to work. Otherwise we might as well all be running Windows as the ‘administrator’ user (and we’ve seen how insecure that is in practice)

Sure it will work, but if there is a bug or vulnerability in Skype then you risk having your machine rooted (owned).

What has been suggested elsewhere is running Skype under another user account. This is a much better idea. eg Something like:

$ su skypeuser -c /Applications/Skype.app/Contents/MacOS/Skype

NB. The password required here is the password of the skypeuser account. Prepend ‘sudo’ if you’re an admin and would rather enter your password.