12-13-2006, 01:25 AM #1sharadaGuestinvoking an application with in another application
i am new to mac.i donot know how to do the things here .
i want to create two applications , i.e. app1 and app2.
All app1 does is invokes app2 if not started. Sleeps for some time (i.e. 60 sec). Then exits.
App1 basically invokes app2 the very first time it is run. Next instance of App1 simply checks to see if App2 is running. If so, prints a message like App2 is already running. So both App1 instances will essentially communicate with App
When one instance of App1 exits, we do not shutdown App2 (since other instance of App1 can still be talking to it).
When second instance of App1 exits (last instance of App1), it shuts down App2 and then exits.i want to write these two applications in "C".
please help me regarding this , if possible send me some code samples.
Thanks & Regards,
12-13-2006, 02:36 PM #2
- Member Since
- Dec 24, 2002
- Los Angeles, California
- 2 x 3.0GHz Quad-Core, 6GB OS X 10.6.8 | 15in MacBook Pro 2.2GHz OS X 10.6.8 | 64GB iPad 2 WiFi
It appears to me, that you want a shell script call app1 and a C application called app2. The shell script app1 will have a loop and a if then statement of sort. It will then check to see if app2 is running if not it start it, and then go to sleep for a short period of time. Upon waking it will check for app2, and repeat the cycle. I don't see app1 communicating with app2, just checking to see if it is up. We would need more to get a feel for what you are trying to do.Life isn't about waiting for the storm to pass, It's about learning to dance in the rain!
12-14-2006, 04:18 AM #3sharadaGuestinvoking an application with in another application
thanks for response ,i donot want to use shell script. first of all i need to run one application sum with in other application Launcher(like create process in windows), Launcher invokes sum if not started. Sleeps for some time (i.e. 60 sec). Then exits.
Launcher basically invokes sum the very first time it is run. Next instance of Launcher simply checks to see if sum is running. If so, print a message like sum is already running. So both Launcher instances will essentially communicate with sum.i need to do the code in pure c. ( nothing but "C") first please ,guide me to this things first.
Thanks & Regards,
12-14-2006, 04:55 AM #4
There are many ways to do this, ranging from the simplistic to the insanely complex. From a terminal, type:
man 3 exec
That will detail how to launch programs from within a C program. Also look at:
man 3 fork
for splitting off new processes.
As for checking if it's already running, you could do it with a simple lock file in the user's home directory, or something complex involving semaphores, signals, shared memory or any number of other IPC mechanisms. It's quite a complex subject; searching the web for 'unix ipc' will give you many pointers.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
By Ryan700 in forum OS X - Operating SystemReplies: 3Last Post: 03-22-2014, 07:30 PM
By kcmn101 in forum OS X - Apps and GamesReplies: 6Last Post: 11-22-2012, 01:34 PM
By AwesomeAttorney in forum OS X - Apps and GamesReplies: 0Last Post: 08-30-2012, 09:10 PM
By ZoSo0789 in forum Switcher HangoutReplies: 2Last Post: 08-05-2010, 07:07 AM
By gadget in forum iOS and AppsReplies: 0Last Post: 02-10-2009, 07:59 PM