Program terminating without any error message

In some situations a program could terminate without even showing an error message. In such cases, the best tool to use and check the problem is

strace

If you dont have it pre-installed, then install it by yum, or using rpms

Yum Command to install strace
yum install strace

This command will install in most redhat based distros.

Install strace using RPM
wget ftp://rpmfind.net/linux/fedora/core/development/i386/os/Fedora/strace-4.5.15-1.fc7.i386.rpm

How to use strace command?

strace [command that crashes here]

For getting help,

# strace --help

usage: strace [-dffhiqrtttTvVxx] [-a column] [-e expr] … [-o file]
[-p pid] … [-s strsize] [-u username] [-E var=val] …
[command [arg …]]
or: strace -c [-e expr] … [-O overhead] [-S sortby] [-E var=val] …
[command [arg …]]
-c — count time, calls, and errors for each syscall and report summary
-f — follow forks, -ff — with output into separate files
-F — attempt to follow vforks, -h — print help message
-i — print instruction pointer at time of syscall
-q — suppress messages about attaching, detaching, etc.
-r — print relative timestamp, -t — absolute timestamp, -tt — with usecs
-T — print time spent in each syscall, -V — print version
-v — verbose mode: print unabbreviated argv, stat, termio[s], etc. args
-x — print non-ascii strings in hex, -xx — print all strings in hex
-a column — alignment COLUMN for printing syscall results (default 40)
-e expr — a qualifying expression: option=[!]all or
option=[!]val1[,val2]…
options: trace, abbrev, verbose, raw, signal, read, or write
-o file — send trace output to FILE instead of stderr
-O overhead — set overhead for tracing syscalls to OVERHEAD usecs
-p pid — trace process with process id PID, may be repeated
-s strsize — limit length of print strings to STRSIZE chars (default 32)
-S sortby — sort syscall counts by: time, calls, name, nothing (default
time)
-u username — run command as username handling setuid and/or setgid
-E var=val — put var=val in the environment for command
-E var — remove var from the environment for command

In rare cases , the command may be a script , And it might internally call other command or program and then it could get mixed up somewhere. So, Simple strace might not help much in this situation.

In those cases

strace -f [command]
will help

It will follow the forks and show detailed strace output for even the internal calls,etc.

you can suppress some unwanted info (for sys admins) like attaching & detaching by using,

strace -q -f [command]

Advanced programmers might look for this as well.

Go through man pages of strace and know more options.
man strace




Leave a Comment

You must be logged in to post a comment.

Google