Sponsored Content
Top Forums Programming Problem on capturing system Shutdown Post 302847699 by Corona688 on Tuesday 27th of August 2013 03:04:25 PM
Old 08-27-2013
Quote:
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.
I think you just answered your own question.
Quote:
The application was going to forcefully terminate after all. At least give it a chance to do a proper cleanup.
You can give it more than a chance -- you can actually do so. Async-safe system calls include open(), close(), read(), and write() among many other things. All you need.

fopen, printf() and its relatives in particular are not signal safe because they allocate memory. You might get away with it by accident but it's system-dependent, compiler-dependent, library-dependent, and luck-dependent. Your code may work all the time on your system and crash all the time on someone else's.

To write code that'll work both here and there, use signal-safe things. That's what they're for.
 

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
Safe Tk(n)						       Tk Built-In Commands							Safe Tk(n)

__________________________________________________________________________________________________________________________________________________

NAME
loadTk - Load Tk into a safe interpreter. SYNOPSIS
::safe::loadTk slave ?-use windowId? ?-display displayName? _________________________________________________________________ DESCRIPTION
Safe Tk is based on Safe Tcl, which provides a mechanism that allows restricted and mediated access to auto-loading and packages for safe interpreters. Safe Tk adds the ability to configure the interpreter for safe Tk operations and load Tk into safe interpreters. The ::safe::loadTk command initializes the required data structures in the named safe interpreter and then loads Tk into it. The inter- preter must have been created with ::safe::interpCreate or have been initialized with ::safe::interpInit. The command returns the name of the safe interpreter. If -use is specified, the window identified by the specified system dependent identifier windowId is used to contain the "." window of the safe interpreter; it can be any valid id, eventually referencing a window belonging to another application. As a convenience, if the window you plan to use is a Tk Window of the application you can use the window name (e.g. .x.y) instead of its window Id ([winfo id .x.y]). When -use is not specified, a new toplevel window is created for the "." window of the safe interpreter. On X11 if you want the embedded window to use another display than the default one, specify it with -display. See the SECURITY ISSUES section below for implementation details. SECURITY ISSUES
Please read the safe manual page for Tcl to learn about the basic security considerations for Safe Tcl. ::safe::loadTk adds the value of tk_library taken from the master interpreter to the virtual access path of the safe interpreter so that auto-loading will work in the safe interpreter. Tk initialization is now safe with respect to not trusting the slave's state for startup. ::safe::loadTk registers the slave's name so when the Tk initialization (Tk_SafeInit) is called and in turn calls the master's ::safe::InitTk it will return the desired argv equivalent (-use windowId, correct -display, etc.) When -use is not used, the new toplevel created is specially decorated so the user is always aware that the user interface presented comes from a potentially unsafe code and can easily delete the corresponding interpreter. On X11, conflicting -use and -display are likely to generate a fatal X error. SEE ALSO
safe(n), interp(n), library(n), load(n), package(n), source(n), unknown(n) KEYWORDS
alias, auto-loading, auto_mkindex, load, master interpreter, safe interpreter, slave interpreter, source Tk 8.0 Safe Tk(n)
All times are GMT -4. The time now is 04:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy