As part of my C application running on Linux, I call a script using the
system( ) library function. This script does a umount of a connected USB flash drive. Very rarely (1 in 7-8k) iterations, I see a segmentation fault,
/bin/sh: line 1: 18083 Segmentation fault (core dumped)
I have verified with debug prints that the failure appears due to the system(). This appears to be a shell crash. I need to understand why a segmentation fault occurred.
My script contains the following code:
mount | grep "USB" ret=$? if [ $ret == "0" ]; then umount -l /mnt/USB ret=$?; if [ $ret -eq 0 ]; then rmdir /mnt/USB fi fi
gdb isn't available on that platform and considering this issue occurs very rarely, it is tough to debug it.