Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

skumar2011

macrumors newbie
Original poster
Dec 19, 2006
26
0
Hi Guys,

I have written two application on Mac,one is using carbon and another one is using cocoa. My both applications get launched and run as a process when Mac OS start because I m launching my applications from StartumItems. Now I don't want to allow any user to force quit my applications from activity monitor, if suppose user force quit the my applications at this point i want to restart the Mac machine automaticaly as soon as my applications gets quit.

Looking for the help.

Thanks,

Sunil
 

Nutter

macrumors 6502
Mar 31, 2005
432
0
London, England
The only way to do this is to have each application monitor the other, and take action if it detects that the other application has quit.

I'm not sure how to do this in Carbon, but in Cocoa's it's very easy: get the workspace notification centre from NSWorkspace and register to receive the notification called "NSWorkspaceDidTerminateApplicationNotification".
 

skumar2011

macrumors newbie
Original poster
Dec 19, 2006
26
0
event notification

thanks guys for quick reply

in reply to the wes this is not a virus type of application

Nutter u mean to say i have to create a thread in my application in that thread i have to continously scan my second application is there in activity monitor or not,if not then it will restart the Mac machine. This will work fine if we simply quit the application form activity monitor and get the notification through NSWorkspaceDidTerminateApplicationNotification API but if i force quit then we won't get any notification through NSWorkspaceDidTerminateApplicationNotification API.

If I m wrong the please correct me.
 

Nutter

macrumors 6502
Mar 31, 2005
432
0
London, England
You will get a notification even if the application is force quit. I wouldn't recommend polling, that's not necessary.

There are uses for this kind of thing that don't involve viruses! However, you may want to consider just relaunching the apps if they are quit rather than restarting the whole system.
 

skumar2011

macrumors newbie
Original poster
Dec 19, 2006
26
0
event notification

thanks Nutter
let me check what u said.
u don't have any idea in carbon?
How to implement same thing in carbon?
as u said in cocoa it is easy to implement.

actualy i hav developed the client and server kind of application using BSD and CFSocket and i m launching my client application through StartupItems. Whenever any particular client get disconnected ,i get the notification server side but which client got disconnect thats i don't know. I have posted this thing how to identify disconnected client on server side while using CFSocket but didn't get any reply.

Can u suggest me any link?
 

gnasher729

Suspended
Nov 25, 2005
17,980
5,566
Hi Guys,

I have written two application on Mac,one is using carbon and another one is using cocoa. My both applications get launched and run as a process when Mac OS start because I m launching my applications from StartumItems. Now I don't want to allow any user to force quit my applications from activity monitor, if suppose user force quit the my applications at this point i want to restart the Mac machine automaticaly as soon as my applications gets quit.

That sounds rather nasty. Trying to implement some malware that starts when the Mac is started, observes each other and restarts the Mac when one is shut down so you can't get rid of it? Good luck.
 

Nutter

macrumors 6502
Mar 31, 2005
432
0
London, England
So the two apps aren't running on the same Mac? In that case, each app will have to spawn a separate process to monitor it. I have no idea how this is done in Carbon.

That sounds rather nasty. Trying to implement some malware that starts when the Mac is started, observes each other and restarts the Mac when one is shut down so you can't get rid of it? Good luck.

This wouldn't be very effective as malware. There's nothing to stop the user removing the applications from their startup items. I presume this is for a legitimate purpose, such as creating a server application that keeps itself running even in the event that it unexpectedly quits.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.