Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am trying to make an app in java that uses some c/c++ code in order to execute some code before computer shutdown,restart,hibernate,sleep or logoff. I was told in the java forum that I had to use c/c++ coding to do this. I was wondering if it would be enough to use the command runlevel in a terminal in my c/c++ app, and if that returns something, then I would send that to my java app, to do the rest. If this is not enough, could someone give me a suggestion as to how I could solve my problem?
Thanks.
Posted
Comments
Sergey Alexandrovich Kryukov 24-Apr-15 0:22am    
Linux? *NIX? You really need to explain a lot more.
—SA

No that is not what you were told. What I said was that you need to find out if Linux provides a mechanism for sending messages to applications to inform them that it is shutting down.
 
Share this answer
 
I found out that you can use signals in linux, to receive that message in a c/c++ app. From what I understand, the signal sigterm is used when the application is terminated, so from what I think, it would be used in restart, shutdown, and logoff, since all the applications are terminated when these buttons are clicked.
What I would like to know is what signal is sent when the computer goes to hibernate or sleep?
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900