Capturing verbose exit codes

2010-04-03 Thread Suvayu Ali
Hi,

Whenever some job is sent to the background and it finishes, it displays 
a message on the shell with the exit code. Something like this;

 [1]-  Doneemacs
 [2]+  Terminated  gedit

I understand that I can get the exit code with $? but is there some way 
I can get the associated message (Done/Terminated/Sementation Fault...) 
with the exit code?

I want to use this in shell function/scripts to notify me whether any of 
my submitted jobs succeeded or failed, and if they failed then with what 
exit code.

Thanks for any insights.

-- 
Suvayu

Open source is the future. It sets us free.
-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines


Re: Capturing verbose exit codes

2010-04-03 Thread Dave Ihnat
On Sat, Apr 03, 2010 at 01:53:40PM -0700, Suvayu Ali wrote:
 Whenever some job is sent to the background and it finishes, it displays 
 a message on the shell with the exit code. ...
 ...
 I understand that I can get the exit code with $? but is there some way 
 I can get the associated message (Done/Terminated/Sementation Fault...) 
 with the exit code?

Unfortunately, every exit code is a function of the individual program
that last ran, or the shellscript itself.  Do a man on the various
commands; you'll find a wide range of exit codes.  About the only thing
you can really count on--usually--is that an exit code of zero means
everything was OK.

Cheers,
--
--
Dave Ihnat
dih...@dminet.com
-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines


Re: Capturing verbose exit codes

2010-04-03 Thread Cameron Simpson
On 03Apr2010 17:07, Dave Ihnat dih...@dminet.com wrote:
| On Sat, Apr 03, 2010 at 01:53:40PM -0700, Suvayu Ali wrote:
|  Whenever some job is sent to the background and it finishes, it displays 
|  a message on the shell with the exit code. ...
|  ...
|  I understand that I can get the exit code with $? but is there some way 
|  I can get the associated message (Done/Terminated/Sementation Fault...) 
|  with the exit code?
| 
| Unfortunately, every exit code is a function of the individual program
| that last ran, or the shellscript itself.  Do a man on the various
| commands; you'll find a wide range of exit codes.  About the only thing
| you can really count on--usually--is that an exit code of zero means
| everything was OK.

However, in the context of Suvayu's query (getting the _shell_'s job
control messages) the codes are universal, since the shell's knowledge
is as non-specific as you describe.

So the shell can report Terminated and Segmentation Fault reliably and
Done versus failed because the wait status has distinct information.
So he should be able to check done versus failed ($? == 0 versus
nonzero), and he may find the shell returns negative values for
terminated by signal N. Core dumps may not be exposed by the shell.

Suvayu: try this:

  sleep 3600 
  kill -9 $!; wait; echo \$?=$?

and repeat with various kill numbers. See if you get anything useful.

Cheers,
-- 
Cameron Simpson c...@zip.com.au DoD#743
http://www.cskk.ezoshosting.com/cs/

Network Planning Constraint Of The Month:
You can't send bits over a non-existant link.
- Valdis Kletnieks val...@vtvm1.cc.vt.edu
-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines


Re: Capturing verbose exit codes

2010-04-03 Thread Suvayu Ali
On Saturday 03 April 2010 04:22 PM, Cameron Simpson wrote:
 On 03Apr2010 17:07, Dave Ihnatdih...@dminet.com  wrote:
 | On Sat, Apr 03, 2010 at 01:53:40PM -0700, Suvayu Ali wrote:
 |  Whenever some job is sent to the background and it finishes, it displays
 |  a message on the shell with the exit code. ...
 |  ...
 |  I understand that I can get the exit code with $? but is there some way
 |  I can get the associated message (Done/Terminated/Sementation Fault...)
 |  with the exit code?
 |
 | Unfortunately, every exit code is a function of the individual program
 | that last ran, or the shellscript itself.  Do a man on the various
 | commands; you'll find a wide range of exit codes.  About the only thing
 | you can really count on--usually--is that an exit code of zero means
 | everything was OK.

 However, in the context of Suvayu's query (getting the _shell_'s job
 control messages) the codes are universal, since the shell's knowledge
 is as non-specific as you describe.

 So the shell can report Terminated and Segmentation Fault reliably and
 Done versus failed because the wait status has distinct information.
 So he should be able to check done versus failed ($? == 0 versus
 nonzero), and he may find the shell returns negative values for
 terminated by signal N. Core dumps may not be exposed by the shell.

 Suvayu: try this:

sleep 3600
kill -9 $!; wait; echo \$?=$?

 and repeat with various kill numbers. See if you get anything useful.


Thank you Cameron for the hints! With some more thinking and some help 
from my roomie, I found something useful to work with. Substituting `n' 
below gives me quite a bit to experiment with. :)

$ sleep 3600 
$ pid=$! ;kill -n $pid;wait $pid;echo $pid exited with $?

 Cheers,

Thanks a lot. :)
-- 
Suvayu

Open source is the future. It sets us free.
-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines


Re: Capturing verbose exit codes

2010-04-03 Thread Cameron Simpson
On 03Apr2010 18:06, Suvayu Ali fatkasuvayu+li...@gmail.com wrote:
| On Saturday 03 April 2010 04:22 PM, Cameron Simpson wrote:
|  So the shell can report Terminated and Segmentation Fault reliably and
|  Done versus failed because the wait status has distinct information.
|  So he should be able to check done versus failed ($? == 0 versus
|  nonzero), and he may find the shell returns negative values for
|  terminated by signal N. Core dumps may not be exposed by the shell.
| 
|  Suvayu: try this:
| 
| sleep 3600
| kill -9 $!; wait; echo \$?=$?
| 
|  and repeat with various kill numbers. See if you get anything useful.
| 
| 
| Thank you Cameron for the hints! With some more thinking and some help 
| from my roomie, I found something useful to work with. Substituting `n' 
| below gives me quite a bit to experiment with. :)
| 
| $ sleep 3600 
| $ pid=$! ;kill -n $pid;wait $pid;echo $pid exited with $?

You should also read man 2 wait and likewise for wait3, wait4 and
waitpid (possibly man 3 blah for some of these, and they may all show
up on the same manpage). That will give you an idea of what information
the shell gets to know after a process exits.

And to get an idea of what you may expect on UNIX systems in general as
opposed to linux in particular, use 3p instead of 2 and 3 above;
that will get you the corresponding POSIX manual on most linux systems.

Cheers,
-- 
Cameron Simpson c...@zip.com.au DoD#743
http://www.cskk.ezoshosting.com/cs/

Besides, it's good to force C programmers to use the toolbox occasionally. :-)
- Larry Wall in 1991may31.181659.28...@jpl-devvax.jpl.nasa.gov
-- 
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines