How can I get dtruss on Mac OS X to track down child processes successfully?

The man page dtruss

says:

       -f     follow children as they are forked

      

which sounds exactly what I want. However, observe the following behavior:

WhiteAndNerdy% uname -a
Darwin WhiteAndNerdy.local 13.4.0 Darwin Kernel Version 13.4.0: Wed Dec 17 19:05:52 PST 2014; root:xnu-2422.115.10~1/RELEASE_X86_64 x86_64
WhiteAndNerdy% sudo dtruss -f -t writev /bin/echo hello world
hello world
    PID/THRD  SYSCALL(args)          = return
37273/0x90e264:  writev(0x1, 0x7F8832D00000, 0x4)        = 12 0

WhiteAndNerdy% sudo dtruss -f -t writev sh -c '/bin/echo hello world'
    PID/THRD  SYSCALL(args)          = return

WhiteAndNerdy% sudo dtruss -f -t writev bash -c '/bin/echo hello world'
    PID/THRD  SYSCALL(args)          = return

WhiteAndNerdy% sudo dtruss -f -t writev zsh -c '/bin/echo hello world'
    PID/THRD  SYSCALL(args)          = return
37295/0x90e39b:  fork()      = 0 0

WhiteAndNerdy% sudo dtruss -f -t writev env /bin/echo hello world
    PID/THRD  SYSCALL(args)          = return

WhiteAndNerdy%

      

Note that except for the first case, "hello world" is not printed. (And it's not just that the result is not visible, and if I start a process that takes a long time, it won't take time in sh -c

such cases. In all the experiments I've done, it seems that execution just stops at the first exec

.)

So I am puzzled as to what it actually does dtruss -f

. How can I get it to behave like strace -f

Linux, which does what I want?

Motivation: I am doing Haskell development on OS X and want to keep track of what happens during startup cabal

(Haskell build system). Performing dtruss -f

on the return cabal without any action at all, because in the version of OS X platform Haskell /usr/bin/cabal

have a shell script, that is exec

/Library/Haskell/bin/cabal.real

. Of course, I can work around this problem by just running /Library/Haskell/bin/cabal.real

directly, but that still won't buy me, as cabal.real

a exec

bunch of other things will just turn around . (Think make

if you are not familiar with Haskell.)

+3


source to share





All Articles