From what I can tell, it appears that the Korn shell will only
handle 8 bit return codes. Is there a way to detect return
codes greater than 256? If a program returns a 16 bit return
code, are 8 bits lost?
Thanks for any info.
Thanks for any info.
- return [n]
Causes a shell function or script to return to the
invoking script with the return status specified
by n. The value will be the least significant 8
^^^^^^^^^^^^^^^^^^^
>>>> bits of the specified status. If n is omitted
then the return status is that of the last command
executed. If return is invoked while not in a
function or a script, then it is the same as an
exit.
------------------------------------------------------------------------
/bin/sh on the other hand will 'return' very high vals from subroutines
but still will not exit higher than 255.
with /bin/ksh you will get nothing higher than 255 whether from a sub
return or an exit.
hope this helps...
SYNOPSIS
int wait (stat_log)
int *stat_loc;
int wait ((int *) 0)
[...]
If stat_loc (taken as an integer) is non-zero, 16 bits of information
called status are store in the low order 16 bits of the location
pointed to by stat_loc.
[...]
If the child process terminated due to an exit call, the low
order 8 bits of status will be zero and the high order 8 bits
will contain the low order 8 bits of the argument that the
child process passed to exit; see exit(2).
So the return code will always be truncated to just the low-order 8 bits
passed to exit(2) by the called process, i.e. this is not just a limitation of
ksh. On a machine with twos-complement binary notation, -1 would be gotten
back by the parent as 255 (within the 8 bit area available for that). Newer
systems have macros such as WIFEXITED(), WEXITSTAT(), etc. defined in
<sys/wait.h> that test to see whether exited, signalled (killed), or
stopped are applicable, and if the macro that tests for one of those
shows true, a corresponding macro is available to extract the interesting
portion of the status info.
If 8 bits of status just isn't enough, you have to pass the data back in
a file or pipe, or with some sort of IPC.
I just tried this with ksh, and it holds. Non-negative exit codes should
be mod 256, negative ones *may* vary according to how signed numbers are
implemented.
--
I compute, therefore I am.
My opinions are strictly by own, and should not be construed to represent
anyone else.
Otherwise, the child process terminated due to a
call to exit(2V). The next byte contains the low-
order 8 bits of the argument that the child process
passed to exit().
--
Barry Margolin
System Manager, Thinking Machines Corp.
1. Trying to run nohup from Korn shell but getting Bourne shell errors
Help! Duh!
I would like to run a process in background with nohup on a
SOLARIS 2.3. How can I get the korn shell script detectsetup
to be interpreted under ksh.
In Korn shell I attempted...
$ /bin/ksh -c "/usr/bin/nohup /export/home/setupin/detectsetup&"
$ [1] 15276
$ Sending output to nohup.out
Checking the process I find....
USER PID PPID COMMAND
pagein 15414 1 sh /export/home/setupin/detectsetup
^
| Why not Korn shell
My nohup.out file errors indicate Bourne shell is interpreting Korn shell
script (doesn't understand integer or [[).
3. Telling Bourne shell from Korn shell at start-up
4. Help! "/dev/lp" - problem with the new HP660 Deskjet
5. Caridge return in unix korn/bourne scripts
6. how to boot YDL without BootX?
7. Light Speed Bourne Shell! (was: Bourne shell tricks)
8. a faster way to gettimeofday?
9. best korn shell resources and is there a korn shell faq
10. How to pipe stderr to a command in Bourne or Korn shell
11. BOURNE/KORN Shell Compiler
12. bourne and korn shell incompatibilities
13. Looking for simple Bourne/Korn shell FIFO queue mechanism :-|