views:

1061

answers:

16

We are making a Jabber client for our internal use in our company and somehow we need to catch the moment when the user tries to kill the program to actually restart it or just make impossible for the user to kill the client.

Is this possible?

Our Jabber client will be written in C#.

How would I go about accomplishing this?

+5  A: 

Not only does this sound like a bad idea (it is abusive to your users) but you will not be able to prevent users from killing the process itself.

You would have to run two separate processes - one to run the application and a second one to monitor the first one and restart it if necessary.

Andrew Hare
If you are so sure of what you are saying then it's enough for me. But I do agree with you though :(
David Hofmann
And then a third to watch the second... :)
jskulski
@David - It sounds like you are caught up in an unfortunate situation, I am truly sorry about that. Just try to make the best of it.
Andrew Hare
just missed it.. :)
Russ Bradberry
+3  A: 

You'll have to reduce their user rights until they can't kill processes.

MatthewMartin
+2  A: 

Control it with a Windows Service. Easy to do in C#. Lock down permissions to stop the service.

Note: I think the answers of "this is impossible/horrible/evil" are perhaps missing your point. A service is specifically designed 'keep going', which is what you're asking about.

Jeffrey Knight
+19  A: 

let me first say, this is a horrible idea.

but...if you must do it, the way I see malicious software and spam hounds do it is to create 3 running processes, one is the main process and the other two will monitor and restart any killed process. it's very difficult for the average user to kill 3 processes simultaneously.

Russ Bradberry
+14  A: 

Sounds like a virus.

David
+4  A: 

You can't. You can make it harder, but not impossible. See The arms race between programs and users.

Adam Rosenfield
+11  A: 

Since this is internal, you could create a separate windows service that monitors the active processes. If the process of your jabber client isn't there, you could just relaunch it.

Then use permissions to keep them from accessing the Windows Service to disable it.

Jab
+1  A: 

You can catch most signals with handlers, except for SIGKILL.

You can create a watch dog windows process that respawns your application in the event it's terminated.

If you want, you can name this process something very innocuous sounding like "sysmon" so it doesn't look as sketchy.

I do hope this is a requirement for work, and not your way to bringing about the downfall of man.

Alan
+1  A: 

sounds like you have access to the jabber client. Can you make it poll to a separate location with it's status and startup time? You aren't disabling the ability to kill it... but at least you can track it and respond from there.

SnOrfus
+35  A: 

What you are asking for has implications far beyond what you are being asked to accomplish. For example, if the process cannot be killed, how can Windows shut down normally?

I don't know your boss, so you will have to gauge their level of understanding for yourself. If a user/manager asked me for this, I would have to probe deeper to find what they really mean. My suspicion is that your users want the default close behavior to minimize to the system tray rather than exit the program, similar to most instant message clients, rather then not be able to ever close the program at all.

Rob Allen
Exactly what I thought when I read the question - if the app won't die by user action, how would Windows be able to close it when shutting down?
GalacticCowboy
A: 

I agree that this is an awful idea.

Having said that, you'd create two programs (probably windows services). Both programs would monitor each other as well as functioning as the client. You would need shared memory that both processes could access to synch which client processes incoming requests.

Garrett
+3  A: 

I think you should go ask the requirement designer what they mean by app that is impossible to "kill." What are they getting at with the word "kill"?

  • Not allowing a user to close their program
    • Prevent standard use of X button in window?
    • Minimize to task tray?
    • Not allow them to close the app in Task Manager?
  • Not allowing the OS to close their program

The requirement is ambiguous enough that I'd go talk to the requirement designer/boss to get a better idea of what they want.

sheepsimulator
+1  A: 

Shouldn't this be controlled by your desktop group? We have PCs in a few kiosks that allow associates to check personal e-mail and stuff (Gmail, Yahoo, Hotmail, etc...), and the user permissions on those PCs will not allow users to kill processes.

Kind of annoying if IE locks up, but I can understand the reasoning.

+1  A: 

Sounds like a case of this

n8wrl
+1  A: 

More importantly, WHY are you rewriting a jabber client when so many good ones, like Miranda and Pidgin already exist? If it's for logging, you can easily do that server side on your Jabber server, and not rely on the clients.

If it's to prevent other IM services, robust firewall rules will help stop that (but it won't prevent it from the super geniuses who'll proxy AIM+Gtalk over https to their home servers).

Chris Kaminski
+1  A: 

Promise to suspend the users who kill your traffic logger Jabber client?

ilya n.