Linux Labs

Inside the system: resources, kernel, processes / Stage 7 of 12

strace and /proc: what a process is doing

Not running Starting usually ~20 s
Leave the lesson

Step 1 of 8 · on a machine · 5 min

The export is silent

What you will learn

  • Run a program under strace and find the call it gave up on.
  • Attach to a running process with sudo strace -p and see which call it is waiting in.
  • Read a process's open files in /proc/<PID>/fd and find with lsof who holds a file.

Every night cron runs the nightsync program: it sends the day's orders to the archive server. This morning nothing was sent, and the cron report only shows exit status 1. Run nightsync yourself and see what it says.

Exercise · look

Run nightsync

In ~/sync-lab, run nightsync, then check the exit status it ended with.

First, predict

nightsync failed during the night. What will it print when you run it by hand?

Now start the exercise, run the command and compare your prediction with the output.

Sign in and start The machine is available after signing in
Check yourself 1 question

nightsync printed nothing and exited with status 1. What do you know for sure from this?

  • Then the shell would write command not found, and the status would be 127. type nightsync shows where the program is.

  • A process killed by a signal exits with 128 + the signal number — 137 after SIGKILL, for example. nightsync has status 1.

  • A successful run ends with status 0, even when there was nothing to do. Status 1 is a failure.

nightsync ran and reported the failure only through status 1.

Ubuntu 24.04
Loading…