UNIX System Call Tracing

Before I finish with tracing, I will mention one more tracing aid—for UNIX system calls. Tracing UNIX system calls is totally outside Tcl and yet that is exactly the reason why it is so valuable. Systems calls are precisely the points at which Tcl interacts with the outside world.

By tracing system calls, you can see files being opened and accessed. You can see when your process is sleeping or creating new processes. You can see signals being sent or received. This kind of information is very useful because, after all, programs are run for the side-effects that they have on the outside world. By tracing system calls, you get an idea of all the side-effects that your script is causing.

I will not go into a lot of detail here because so much of this is system specific. However, there are three programs that are particularly useful. truss is a very flexible system call tracer that is found on System V derivatives. trace is a similar program that is found on BSD-based systems. strace is a public-domain version of trace that is a lot better than the original. I highly recommend getting familiar with at least one of these tools.

Get Exploring Expect now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.