exit(3) Library Functions Manual exit(3)Name
exit - terminate a process after flushing any pending output
Syntax
void exit(status)
int status;
int atexit(func)
void (*func)();
Description
The function terminates a process after calling the Standard I/O library function, _cleanup, to flush any buffered output. The function
never returns.
The function registers a function to be called (without arguments) at normal program termination; functions are called in the reverse order
of their registration (that is, most recent first). If a function is registered more than once, it will be called more than once.
Return Values
The function returns zero if the registration succeeds, or -1 if the function pointer is null or if too many functions are registered.
See Alsoexit(2), intro(3s)exit(3)
Check Out this Related Man Page
atexit(3C) Standard C Library Functions atexit(3C)NAME
atexit - register a function to run at process termination or object unloading
SYNOPSIS
#include <stdlib.h>
int atexit(void (*func)(void));
DESCRIPTION
The atexit() function registers the function pointed to by func to be called without arguments on normal termination of the program or when
the object defining the function is unloaded.
Normal termination occurs by either a call to the exit(3C) function or a return from main(). Object unloading occurs when a call to
dlclose(3C) results in the object becoming unreferenced.
The number of functions that may be registered with atexit() is limited only by available memory (refer to the _SC_ATEXIT_MAX argument of
sysconf(3C)).
After a successful call to any of the exec(2) functions, any functions previously registered by atexit() are no longer registered.
On process exit, functions are called in the reverse order of their registration. On object unloading, any functions belonging to an
unloadable object are called in the reverse order of their registration.
RETURN VALUES
Upon successful completion, the atexit() function returns 0. Otherwise, it returns a non-zero value.
ERRORS
The atexit() function may fail if:
ENOMEM Insufficient storage space is available.
USAGE
The functions registered by a call to atexit() must return to ensure that all registered functions are called.
There is no way for an application to tell how many functions have already been registered with atexit().
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
|MT-Level |Safe |
+-----------------------------+-----------------------------+
SEE ALSO exec(2), dlclose(3C), exit(3C), sysconf(3C), attributes(5)SunOS 5.10 25 May 2001 atexit(3C)
I wonder if someone could help me here. I am trying to find a way of exiting from a loop but not exiting me from the script for example
#!/bin/ksh
# ************* FUNCTIONS ******************
function1() { #ping test
ping $1 2 > /dev/null
if ; then
... (13 Replies)
Having searched high and low through Oracles documentation, I came to think that they're very scripting-averse, as there's (apparently) no list of possible return/exit codes for their various command line utilities.
Is anyone here in possession of such a list, or knows where to find one? It... (16 Replies)
Hi Guys,
I have a script which takes reply from user and executes the corresponding scirpt. Below is the script
PS3 = 'Enter the options of your choice(x to exit)=>'
select useropt in 'List Processess' \
'List semaphores'
do
case $REPLY in
1) abc.sh
... (13 Replies)
Dear,
I have written below code to initiate the log at top of my script.
#Set the log file
LOGFILE=<path>/<filename.log>
exec > $LOGFILE 2>&1
...............
....
...
..
............
echo -e "\n\n Script finished OK " `date "+%m/%d/%y %H:%M:%S" ` "\n\n"
exit 0
the logging ends only... (14 Replies)
Hi there,
OK so I am super-green, but I have a problem I am hoping someone can help me with. I have a V245 that I am unable to install Solaris 10 (10/09) onto as during the initial install process, the UI pops up for region selection, but then as I enter my region, identify the system, up comes... (21 Replies)
Lois_Answer_Code=`sipsak -vv -s sip:192.168.1.3|grep -A 1 "reply received after"|grep SIP|awk '{print $2}'`How to find the exit status of | (12 Replies)
hi
i am new to shell scripting.
i was going thru the part option and arguments. on this section i fail to understand the use of exit 0 in below example .
#!/bin/sh
USAGE="Usage: $0 "
case "$1" in
-t) TARGS="-tvf $2" ;;
-c) TARGS="-cvf $2.tar $2" ;;
*) echo "$USAGE"
exit 0
;;
esac... (13 Replies)
I have just installed AIX 7.1 on a new system, and find that it displays the same annoying behaviour the you find in Linux:
In an xterm, when you quit vim or less, the file listed in the terminal window is blanked out and replaced with whatever was there before.
In vim there is a couple of... (12 Replies)
We are trying to design a flow so that an ETL job shouldn't start until the previous job completes. The script we have written is
while ; do sleep 2; done
The loop however exits even when the process is actually running. Why could this be happening? (12 Replies)
Hi
I have 3 files in total. file 1 is enriched.txt file2 is repressed.txt and file 3 is my content.txt
What i need is query the content file against both enriched and repressed and wherever the gensymbol is same in both the files then add a yes value against it
file1
Gene
ABC
XYZ
MNO... (12 Replies)
Hi,
I am getting scheduler log file on daily basis from windows box which contains job status and corresponding date, date is in windows format.
I wanted to write one script which will search the pattern (Exit code) for the today's date and if code is Zero then Job Success message should be... (14 Replies)
Heyas,
Since this question (similar) occur every now and then, and given the fact i was thinking about it just recently (1-2 weeks) anyway, i started to write something :p
The last point for motivation was... (17 Replies)
Hi,
I am trying to capture logs of the script in the file as well as on the screen. I have used exec and tee command for this. While using exec command I am getting the correct output in the file but, script output is not getting displayed on the screen as it get executed.
Below is my sample... (14 Replies)
How to return a exit code from a function and use it in conditional?
I tried the following but it does not seem to work.
tests.sh:
if test ./load.sh ; then
echo "0"
else
echo "1"
fi
load.sh:
return 1;
from command line:
$ ./tests.sh
0
I was expecting it to output "1"... (17 Replies)
Running Xubuntu 16.04 with shell version "GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)," I have a working script that consistently renames a Chrome window:
#!/bin/sh
while sleep 1; do
xdotool search --name chrome 2>/dev/null | while read id; do
xdotool set_window --name... (21 Replies)