[Thread Prev][Thread Next][Index]

Re: [ferret_users]



Patrick and Ansley,

| Starting
| with Ferret v6.64, if Ferret crashes, and if it can catch the errors
| SIGILL, SIGFPE, and SIGSEGV, then it returns a -1 status code.

Interesting!  In that case, to get a non-zero exit status, you can end
your Ferret script with something along the lines of

  SP kill -FPE \`cat /proc/$$/stat | awk '{print $4}'\`

to kill "itself" with SIGFPE, thereby exiting with a non-zero
status.

You could put this one line in a separate script, say
"error-exit.jnl", and call it like

  go error-exit

to get the same effect. (Tested.)

Caveat: The part

  cat /proc/$$/stat | awk '{print $4}'

is a trick to get the parent PID on Linux, which may not work
on other Unix systems.  In that case you would have to find
another trick such as processing the output from the ps command.

Is there a simpler way to obtain the process ID of the current
Ferret session?

Ferret's "SP" command creates a child process in which to run the
command line.  So, you want to kill the parent of the subprocess. 
To do that, you have to find out the process ID of the parent
(Ferret).

Regards,
Ryo


[Thread Prev][Thread Next][Index]

Contact Us
Dept of Commerce / NOAA / OAR / PMEL / TMAP

Privacy Policy | Disclaimer | Accessibility Statement