I want to write simple strace-like script using SystemTap. Main goal is to catch only some system calls (like open, close, read, write etc.) for all processes in system. (Can't do that with strace because strace'ing whole system is equal to instant system freeze).
For now it goes like this:
#!/usr/bin/env stap
probe syscall.*
{
printf("PID: %d\tNAME: %s\tARGSTR: %s\n",pid(), name, argstr);
}
The problem starts when I want to save output to file. Stap script is constantly finding itself writing to file so it's never ending loop.
I think the solution would be something like this:
#!/usr/bin/env stap probe syscall.* { if(pid() != myOwnPid()) printf("PID: %d\tNAME: %s\tARGSTR: %s\n",pid(), name, argstr); }
But I don't know any function giving pid of running stap script.