Page MenuHomeFreeBSD

dtrace(1) handle SIGPIPE, and handle signals when listing probes
ClosedPublic

Authored by markj on Oct 2 2014, 12:51 AM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 19 2023, 10:13 PM
Unknown Object (File)
Sep 12 2023, 12:43 PM
Unknown Object (File)
Sep 2 2023, 1:31 AM
Unknown Object (File)
Jul 12 2023, 2:08 AM
Unknown Object (File)
Jun 21 2023, 6:58 AM
Unknown Object (File)
May 18 2023, 7:11 AM
Unknown Object (File)
May 16 2023, 2:41 AM
Unknown Object (File)
May 2 2023, 7:38 PM
Subscribers
None

Details

Summary

It's occasionally useful to do something like

dtrace -lv -P 'pid$target' -p <target PID> | less

to browse the pid provider probes of the target process. However, quitting less(1) will cause dtrace to receive SIGPIPE and exit, which in turn causes the target process to exit since it's being ptrace(2)ed. It's also conceivably useful to run the output of a dtrace script through a pipe.

This change does two things. First, it installs a handler for SIGPIPE - the same handler that's currently used for SIGQUIT and SIGINT. If a dtrace program is executing, it'll cleanup and exit if it sees SIGPIPE. Second, in list mode (-l), it'll break out of the for-each-probe loop and clean up.

Test Plan

The above example would reliably kill the target process. Now dtrace exits cleanly, and the target process is able to continue running. Similarly, ctrl-Cing dtrace when it was attached to a process and listing a large number of probes would cause the target process to be killed; that no longer happens.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

markj retitled this revision from to dtrace(1) handle SIGPIPE, and handle signals when listing probes.
markj updated this object.
markj edited the test plan for this revision. (Show Details)
markj added a reviewer: DTrace.
rpaulo added a reviewer: rpaulo.
This revision is now accepted and ready to land.Oct 2 2014, 1:35 AM
markj updated this revision to Diff 1869.

Closed by commit rS272455 (authored by @markj).