1STRACE(1)                   General Commands Manual                  STRACE(1)
2
3
4

NAME

6       strace - trace system calls and signals
7

SYNOPSIS

9       strace [-ACdffhikqqrtttTvVwxxyyzZ] [-I n] [-b execve] [-e expr]...
10              [-O overhead] [-S sortby] [-U columns] [-a column] [-o file]
11              [-s strsize] [-X format] [-P path]... [-p pid]...
12              [--seccomp-bpf] { -p pid | [-DDD] [-E var[=val]]...
13              [-u username] command [args] }
14
15       strace -c [-dfwzZ] [-I n] [-b execve] [-e expr]... [-O overhead]
16              [-S sortby] [-U columns] [-P path]... [-p pid]...
17              [--seccomp-bpf] { -p pid | [-DDD] [-E var[=val]]...
18              [-u username] command [args] }
19

DESCRIPTION

21       In the simplest case strace runs the specified command until it  exits.
22       It  intercepts  and  records  the  system  calls  which are called by a
23       process and the signals which are received by a process.  The  name  of
24       each  system  call,  its  arguments and its return value are printed on
25       standard error or to the file specified with the -o option.
26
27       strace is a useful diagnostic, instructional, and debugging tool.  Sys‐
28       tem  administrators,  diagnosticians  and trouble-shooters will find it
29       invaluable for solving problems with programs for which the  source  is
30       not  readily available since they do not need to be recompiled in order
31       to trace them.  Students, hackers and the overly-curious will find that
32       a  great  deal  can  be  learned about a system and its system calls by
33       tracing even ordinary programs.  And programmers will find  that  since
34       system  calls  and  signals  are  events that happen at the user/kernel
35       interface, a close examination of this boundary is very useful for  bug
36       isolation, sanity checking and attempting to capture race conditions.
37
38       Each  line  in the trace contains the system call name, followed by its
39       arguments in parentheses and its return value.  An example from  strac‐
40       ing the command "cat /dev/null" is:
41
42           open("/dev/null", O_RDONLY) = 3
43
44       Errors (typically a return value of -1) have the errno symbol and error
45       string appended.
46
47           open("/foo/bar", O_RDONLY) = -1 ENOENT (No such file or directory)
48
49       Signals are printed as signal symbol and decoded siginfo structure.  An
50       excerpt from stracing and interrupting the command "sleep 666" is:
51
52           sigsuspend([] <unfinished ...>
53           --- SIGINT {si_signo=SIGINT, si_code=SI_USER, si_pid=...} ---
54           +++ killed by SIGINT +++
55
56       If  a  system call is being executed and meanwhile another one is being
57       called from a different thread/process then strace will try to preserve
58       the  order  of  those  events and mark the ongoing call as being unfin‐
59       ished.