Operating System - HP-UX
1834644 Members
2454 Online
110069 Solutions
New Discussion

Re: Coredump in kornshell but not in possix?

 
SOLVED
Go to solution
Danny Engelbarts
Frequent Advisor

Coredump in kornshell but not in possix?

Hi,

I noticed something weird in the kornshell, the attached script will generate a memory fault (SIGSEGV) when executed using /usr/bin/ksh but when the first line is changed to #!/usr/bin/sh it will run without any problems! Does anyone have a clue what's going on? (Seems like a bug to me ...)

Greetz, Danny
9 REPLIES 9
Dave Kelly_1
Respected Contributor

Re: Coredump in kornshell but not in possix?

I've just run your script on my 10.20 system without a problem.

What OS do you have ? Patches ?

Can you also supply the stderr output seeing as you included set -x in the script. It would be good to see exactly where the SIGSEGV is occurring.
Danny Engelbarts
Frequent Advisor

Re: Coredump in kornshell but not in possix?

Hey Dave,

Here's some more info (attachment), although i did include the set -x there is no debug output?
I ran the original on a 10.10 system, i've tried on 10.20 as well and i get the same error.

Greetz, Danny.
Rainer_1
Honored Contributor
Solution

Re: Coredump in kornshell but not in possix?

don't know why but the problem points to the shift statement within the while getopts ... do ... done loop
Remove the shift line and add after the loop

shift $(($OPTIND -1))

then the script runs at both shells
Danny Engelbarts
Frequent Advisor

Re: Coredump in kornshell but not in possix?

Yep! That's it ... still wondering why now ;o)

Thanks! Danny.
Carlos Fernandez Riera
Honored Contributor

Re: Coredump in kornshell but not in possix?


Your problem is you are making too shifts ( more than arguments).

insert echo $# $* before shift and run.

See man getopts:

thera are an example that use shift out of loop and ussing $OPTIND.


HTH
unsupported
Danny Engelbarts
Frequent Advisor

Re: Coredump in kornshell but not in possix?

Hmmm,

If i read the manual correctly getopts should only walk through the "legal options" i.e. all options with either a preceding - or + sign. But it seems the implementation in the kornshell walks through the other options as well?

Danny.
Carlos Fernandez Riera
Honored Contributor

Re: Coredump in kornshell but not in possix?


I understand that getopts may search over all args to find all options.

For your script perhaps you will prefer:

DiffTime -h -s time -e time

and getopt hs:e:.

See man 3c getopt too.



unsupported
CHRIS_ANORUO
Honored Contributor

Re: Coredump in kornshell but not in possix?

Hi Danny,

Check with this command "swlist -l fileset|grep sh" to see if you have patch PHKL_19762 installed on your server.
The patch is a fix for debugging shared lib gets SIGSEGV problem.
When We Seek To Discover The Best In Others, We Somehow Bring Out The Best In Ourselves.
Bill Hassell
Honored Contributor

Re: Coredump in kornshell but not in possix?

Just a note about debugging (tracing with set -x): the trace output will go to stderr. So to trace a shell script with all output into a file:

sh -x myscript arg1 arg2 > /var/tmp/tracefile 2>&1



Bill Hassell, sysadmin