Sponsored Content
Top Forums Programming Problem on capturing system Shutdown Post 302847687 by hakermania on Tuesday 27th of August 2013 02:55:05 PM
Old 08-27-2013
I just downloaded the source code of ettercap-graphical (a well know application) and it doesn't use async-safe functions in the code (fprintf is being used, user interface is being normally shut down, the log file is flushed and closed). So how "strict" is it to make async-safe functions?

I also have this simple question: Why not use async-unsafe functions after all? The worse thing that could happen would be the application to crash or to be in a loop easily terminated with SIGKILL. The application was going to forcefully terminate after all. At least give it a chance to do a proper cleanup.

As for simulating shutdown: Now I am simulating shutdown with simply sending SIGTERM to my process. As I said before, this is not the only thing that really happens, because when I send SIGTERM it runs the handler without any problem. So, the system does something else that I am unaware of (I highly doubt that it really spends time on checking whether the function that is to be called is async-safe or not). So, I simply asked whether there is a better way to simulate the shutdown for only one process, because simply sending SIGTERM is not the best way. I don't believe I am being irrational.
 

8 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Capturing Oracle Shutdown error

Hi, Iam calling 3 sql scripts through one shell script 'rmia.sh'. Till now this was working fine, but last time while calling the SQL scripts, Oracle was down. But amazingly the exit status was '0' (success)!!! Below is the shell code: #!/usr/bin/ksh -x assign_file asql a.sql 1... (15 Replies)
Discussion started by: ganapati
15 Replies

2. Shell Programming and Scripting

Shutdown a system by MAC?

Ok here is the problem we have 2 v440 with same IP address running solars 9. one remains on the other remains off. They are both configured exactly the same for redundant purposes for the software we use. This was the best/worst idea. Great because down time is only a mere minutes. The bad is the... (7 Replies)
Discussion started by: deaconf19
7 Replies

3. Solaris

logs for system shutdown

I am working on a SUN T2000 machine with Solaris 10 running on it. When I checked the system this morning, I found it to be turned off. The lastreboot command showed that the system had been shut down the previous night. I want to find out how the system was shut down. I have run hardware health... (2 Replies)
Discussion started by: batman727
2 Replies

4. Shell Programming and Scripting

Sending mail on system shutdown

I want to only send a mail before my system goes for a shutdown or reboot. I don't want a mail when it comes up after a reboot or is normally started.. How can i achieve this? (2 Replies)
Discussion started by: proactiveaditya
2 Replies

5. Windows & DOS: Issues & Discussions

system restarts after shutdown!!

Hello, from last few days my laptop is not whutting down properly.. when ever i ty to shutdown it restarts again.. what may be problem?? antivirus is updated till date.. and i use windows xp sp2.... regards, deepak. (5 Replies)
Discussion started by: smarty86
5 Replies

6. Shell Programming and Scripting

Capturing awk's system(cmd) output

Hi everybody, I am working on a bigger awk script in which one part is comparing the size of two files. I want to evaluate which file is bigger and then just save the bigger one. I got it all working except for the part where I want to figure out which file is bigger; the one awk is currently... (2 Replies)
Discussion started by: iMeal
2 Replies

7. Solaris

Shutdown system option

I am working on sunos solaris. I want to know which is good for system shut-down ? (3 Replies)
Discussion started by: Jitesh Varshney
3 Replies

8. Red Hat

shutdown system/myeclipse

Hi All, I have one situation to shut-down the system through shell script.I need script command to shut-down the system and process should end(safe-mode) the MyEclipse. (0 Replies)
Discussion started by: stsivaraj
0 Replies
SHUTDOWNHOOK_ESTABLISH(9)				   BSD Kernel Developer's Manual				 SHUTDOWNHOOK_ESTABLISH(9)

NAME
shutdownhook_establish, shutdownhook_disestablish -- add or remove a shutdown hook SYNOPSIS
void * shutdownhook_establish(void (*fn)(void *), void *arg); void shutdownhook_disestablish(void *cookie); DESCRIPTION
The shutdownhook_establish API is deprecated. The shutdownhook_establish() function adds fn to the list of hooks invoked by doshutdownhooks(9) at shutdown. When invoked, the hook func- tion fn will be passed arg as its only argument. The shutdownhook_disestablish() function removes the hook described by the opaque pointer cookie from the list of hooks to be invoked at shutdown. If cookie is invalid, the result of shutdownhook_disestablish() is undefined. Shutdown hooks should be used to perform one-time activities that must happen immediately before the kernel exits. Because of the environ- ment in which they are run, shutdown hooks cannot rely on many system services (including file systems, and timeouts and other interrupt- driven services), or even basic system integrity (because the system could be rebooting after a crash). RETURN VALUES
If successful, shutdownhook_establish() returns an opaque pointer describing the newly-established shutdown hook. Otherwise, it returns NULL. EXAMPLES
It may be appropriate to use a shutdown hook to disable a device that does direct memory access, so that the device will not try to access memory while the system is rebooting. It may be appropriate to use a shutdown hook to inform watchdog timer hardware that the operating system is no longer running. SEE ALSO
doshutdownhooks(9) BUGS
The names are clumsy, at best. BSD
May 14, 2009 BSD
All times are GMT -4. The time now is 12:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy