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
PTHREAD_ATFORK(3)					   BSD Library Functions Manual 					 PTHREAD_ATFORK(3)

NAME
pthread_atfork -- register handlers to be called when process forks LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <pthread.h> int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)); DESCRIPTION
The pthread_atfork() function registers the provided handler functions to be called when the fork(2) function is called. Each of the three handlers is called at a different place in the fork(2) sequence. The prepare handler is called in the parent process before the fork hap- pens, the parent handler is called in the parent process after the fork has happened, and the child handler is called in the child process after the fork has happened. The parent and child handlers are called in the order in which they were registered, while the prepare handlers are called in reverse of the order in which they were registered. Any of the handlers given may be NULL. The intended use of pthread_atfork() is to provide a consistent state to a child process from a multithreaded parent process where locks may be acquired and released asynchronously with respect to the fork(2) call. Each subsystem with locks that are used in a child process should register handlers with pthread_atfork() that acquires those locks in the prepare handler and releases them in the parent handler. RETURN VALUES
The pthread_atfork() function returns 0 on success and an error number on failure. ERRORS
The following error code may be returned: [ENOMEM] Insufficient memory exists to register the fork handlers. SEE ALSO
fork(2) STANDARDS
The pthread_atfork() function conforms to IEEE Std 1003.1c-1995 (``POSIX.1''). HISTORY
The pthread_atfork() function first appeared in NetBSD 2.0. CAVEATS
After calling fork(2) from a multithreaded process, it is only safe to call async-signal-safe functions until calling one of the exec(3) functions. The pthread_*() functions are not async-signal-safe, so it is not safe to use such functions in the child handler. BUGS
There is no way to unregister a handler registered with pthread_atfork(). BSD
February 12, 2003 BSD
All times are GMT -4. The time now is 04:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy