# Write yourself an strace in 70 lines of code

DevFeed: [Write yourself an strace in 70 lines of code](<https://devfeed.tech/articles/write-yourself-an-strace-in-70-lines-of-code-21916.md>)

Original publisher: [Read original article](<https://blog.nelhage.com/2010/08/write-yourself-an-strace-in-70-lines-of-code/>)

Author: Nelson Elhage

Published: 2010-08-29T12:33:26Z

Content type: tutorial

Language: en

Sources: [Nelson Elhage](<https://devfeed.tech/sources/nelson-elhage.md>)

Topics: [C](<https://devfeed.tech/topics/c.md>), [Code](<https://devfeed.tech/topics/code.md>), [Linux](<https://devfeed.tech/topics/linux.md>), [Kernel](<https://devfeed.tech/topics/kernel.md>), [Processes](<https://devfeed.tech/topics/processes.md>), [Unix](<https://devfeed.tech/topics/unix.md>)

Tags: [c](<https://devfeed.tech/tags/c.md>), [code](<https://devfeed.tech/tags/code.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [kernel](<https://devfeed.tech/tags/kernel.md>), [linux](<https://devfeed.tech/tags/linux.md>), [processes](<https://devfeed.tech/tags/processes.md>), [unix](<https://devfeed.tech/tags/unix.md>)

## AI overview

This tutorial explains how strace traces system calls made by Linux programs and walks through implementing a minimal version in about 70 lines of C. It introduces the process-tracing interface and demonstrates monitoring system-call events, numbers, and return values.

## Source excerpt

Basically anyone who's used Linux for any amount of time eventually comes to know and love the strace command. strace is the system-call tracer, which traces the calls that a program makes into the kernel in order to interact with the outside world. If you're not already familiar with this incredibly versatile tool, I suggest you go check out my friend and coworker Greg Price's excellent blog post on the subject, and then come back here.