TRACE(1)

NAME
trace - trace system calls and signals

SYNOPSIS
trace [ -ct ] [ -o filename ] command

trace [ -ct ] [ -o filename ] -p pid

DESCRIPTION

trace runs the specified command until it exits. It intercepts the system calls and signals of a process. The name of the system call, its arguments and result are listed on the standard output.

Each line in the trace contains the system call name, followed by its arguments in parentheses and its result. Error returns (result = -1) have the error name and error message appended. Signals are printed as a signal name followed by the signal number. Arguments are printed according to their type. Structure pointers are always printed as hex addresses. Character pointers are dereferenced and printed as a quoted string. Non-printing characters in strings are represented by escape codes. Only the first 32 bytes of strings are printed; longer strings have two dots appended following the closing quote.

    The quick brown fox jumps over t ..

Strings with more than 50% non-printing characters are assumed to contain binary data and are represented by a null string followed by two dots.

    ""..

OPTIONS

-c  Print a quick summary of system call and signal counts, instead of printing a full trace.

-t  Prefix each line of the trace with the time of day.

-o filename
    Write the trace output to the file filename rather than to the standard output.

-p pid
    Attach to the process with the process ID pid and begin tracing. The trace may be terminated at any time by a keyboard interrupt signal (CTRL-C); trace will respond by detaching itself from the traced process leaving it to continue running.

EXAMPLES
example% trace date
gettimeofday (0x21474, 0x2147c) = 0
gettimeofday (0x21474, 0) = 0
gettimeofday (0xefffc78, 0x214ac) = 0
ioctl (1, 0x40067408, 0xefffa10) = -1 ENOTTY (Inappropriate ioctl for device)
fstat (1, 0xefffa30) = 0
getpagesize () = 8192
brk (0x27640) = 0
close (0) = 0
Thu Dec  4 14:16:36 PST 1986
write (1, "Thu Dec  4 14:16:36 PST 1986\n", 29) = 29
close (1) = 0
close (2) = 0
exit (0) = ?
example%

SEE ALSO
ptrace(2)

NOTES
A process that has a system call trace applied to it with the -p option will receive a SIGSTOP. This signal may interrupt a system call that is not restartable. This may have an unpredictable effect on the process if the process takes no action to restart the system call.

BUGS

Programs that use the setuid bit do not have effective user ID privileges while being traced.

Child processes of a traced process are not traced.

A traced process ignores SIGSTOP.

A traced process runs slowly.