Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

on_exit(3) [redhat man page]

ON_EXIT(3)						     Linux Programmer's Manual							ON_EXIT(3)

NAME
on_exit - register a function to be called at normal program termination. SYNOPSIS
#include <stdlib.h> int on_exit(void (*function)(int , void *), void *arg); DESCRIPTION
The on_exit() function registers the given function to be called at normal program termination, whether via exit(3) or via return from the program's main. The function is passed the argument to exit(3) and the arg argument from on_exit(). RETURN VALUE
The on_exit() function returns the value 0 if successful; otherwise it returns a non-zero value. CONFORMING TO
This function comes from SunOS, but is also present in libc4, libc5 and glibc. SEE ALSO
atexit(3), exit(3) GNU
1993-04-02 ON_EXIT(3)

Check Out this Related Man Page

ON_EXIT(3)						     Linux Programmer's Manual							ON_EXIT(3)

NAME
on_exit - register a function to be called at normal process termination SYNOPSIS
#include <stdlib.h> int on_exit(void (*function)(int , void *), void *arg); Feature Test Macro Requirements for glibc (see feature_test_macros(7)): on_exit(): _BSD_SOURCE || _SVID_SOURCE DESCRIPTION
The on_exit() function registers the given function to be called at normal process termination, whether via exit(3) or via return from the program's main(). The function is passed the status argument given to the last call to exit(3) and the arg argument from on_exit(). The same function may be registered multiple times: it is called once for each registration. When a child process is created via fork(2), it inherits copies of its parent's registrations. Upon a successful call to one of the exec(3) functions, all registrations are removed. RETURN VALUE
The on_exit() function returns the value 0 if successful; otherwise it returns a nonzero value. CONFORMING TO
This function comes from SunOS 4, but is also present in libc4, libc5 and glibc. It no longer occurs in Solaris (SunOS 5). Avoid this function, and use the standard atexit(3) instead. SEE ALSO
_exit(2), atexit(3), exit(3) COLOPHON
This page is part of release 3.25 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. GNU
2008-12-05 ON_EXIT(3)
Man Page

15 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Tidying up temp files on exit of script

Hi I believe there is a method to remove all temporary files when a KSH script terminates (either expectedly or unexpectedly). I think is some sort of subroutine you can create that runs when the script exits. Can anyone help me with this please? Many thanks Helen :confused: (2 Replies)
Discussion started by: Bab00shka
2 Replies

2. Shell Programming and Scripting

application exit kills shells

Hi all, I start my application from a shell command-line. When I exit my application, it kills the shell that its returning too. Worse yet, since I have init respawning the shell all those subsequent shells get killed automatically...so I get output like the following (the >> is the prompt for... (2 Replies)
Discussion started by: q1001001
2 Replies

3. Linux

How to stop linux man pages from clearing on exit?

Whenever I quit out of reading a man page, it clears the screen. I do not like this behavior, as I'd like to keep part of the man page on the screen while I type out a command. How do I stop this behavior? (6 Replies)
Discussion started by: akbar
6 Replies

4. UNIX for Advanced & Expert Users

sftp hanging on exit

Hi, I am doing a sftp from solaris 2.8 box to windows XP box. I am able to transfer the files successfully from the windows box to Solaris box (that is only I need). Problem arises when I try to exit/quit from the sftp session. sftp gets hung and I have to kill the telnet session by closing... (1 Reply)
Discussion started by: max29583
1 Replies

5. Shell Programming and Scripting

ZSH - '.zlogout' not being run on exit

Hi, I have a problem with '.zlogout' not being run on Solaris 10. Here's whats happening. I remotely log in from a PC running Cygwin/X using a local xterm window and ssh to start a remote 'zsh' shell, version 4.2.5, on a Solaris 10 server. The Server has KDE installed but as a Window... (0 Replies)
Discussion started by: stv_t
0 Replies

6. UNIX for Dummies Questions & Answers

X11 hangs on exit

Hi all, does anyone know an easy to read manual for newbies introducing X11 - more specifically how to open windows, resizing them, etc...? I namely installed FreeBSD 7.0 on an old HP omnibook xe4100 notebook because it's less demanding in resources. So far so good, everything went smooth... (0 Replies)
Discussion started by: erparis
0 Replies

7. Shell Programming and Scripting

TRAP Command --use based on exit criteria

Hi all, I am using the trap command in my script, and I want it to trap the signal based on the exit code the script returns. can anybody tell me how can I use "if loop" for "trap" command. I want to print "terminated by user" if signal is SIGINT or 2 "failure" if signal is not 2 and not 0... (1 Reply)
Discussion started by: grep_me
1 Replies

8. AIX

Aix xlc interesting SEGV on exit

Hello all, One of the application we port to Aix from linux Segmentation faults when it exits. Here is part of backtrace of SEGV: (dbx) where splay(??, ??, ??) at free_y(??, ??) at free_common(??) at .... exit(??) at ... Application seem to perform everything expected well and... (1 Reply)
Discussion started by: qrio.qrio
1 Replies

9. Programming

C++ Segmentation Fault on exit of main

Hi, I have 2 problems with a simple C++ app which i feel may be related. 1/ my app throws a Segmentaion Fault when my code exists from main(). I have stripped it to it's simplest form with no code in main and it still generates a segmentation fault. I'm not sure what is causing this,... (9 Replies)
Discussion started by: SonOfPerdition
9 Replies

10. Shell Programming and Scripting

Terminal is closing on exit in ksh

hi while executing the following script, my terminal window is getting closed if I enter a invalid option. I want the script should go back the the command prompt. how to do achive it. i execute the script as . ./test #! /usr/bin/ksh Printf " Type of Installer : \n\t\t 1. Whole Build... (3 Replies)
Discussion started by: vij_krr
3 Replies

11. Shell Programming and Scripting

ssh hangs on exit

Hi, Any workaround for this issue, since i am using one script to execute the remote script for several remote server, everything works fine except some of the servers process are hangs even its completed. ---Please help me to resolve this issue---- Script details are here.. for... (2 Replies)
Discussion started by: l_gshankar24
2 Replies

12. Shell Programming and Scripting

Need urgent help on exit status of the script

Guys, I am writing a script that executes a series of commands with a function like: _Command "ps -ef | grep java" _Command "vmstat" _Command "llll" Even if one of these commands fail, my script should exit with non-zero code i.e 16. If all commands are successful, my script should exit... (7 Replies)
Discussion started by: sriramperumalla
7 Replies

13. Shell Programming and Scripting

Script returning an error message on exiting

Hi, I am writing a script in which I am using an IF-Else statement. Code sample: # Check for the product. If (test "$3" = "Pet") Then Product_Code="PI" elif (test "$3" = "Breakdown") Then Product_Code="RI" elif (test "$3" = "Travel") Then Product_Code="TI" ... (2 Replies)
Discussion started by: bghosh
2 Replies

14. Shell Programming and Scripting

Time condition exit loop

Hi All, Requirement: The below script should automatically exit at 6pm everyday without manually killing the script Tried running with the below shell script but found the script was still running when the time was 6:15pm. The script did not exit the while loop at 6pm The script runs... (6 Replies)
Discussion started by: a1_win
6 Replies

15. Shell Programming and Scripting

[Solved] Rsh does not close connection on exit

Dear all, We have a service that we start up remotely with rsh but unfortunately, the rsh never returns to the calling server. This seems to be because the processes of the service we've just started hold the port open.RBATTE1 @ /home/RBATTE1>netstat -na|grep 49.51 tcp4 0 0 ... (1 Reply)
Discussion started by: rbatte1
1 Replies