[PATCH v5 1/3] Introduce -l/--syscall-limit option

Sahil Siddiq icegambit91 at gmail.com
Sun Mar 26 15:04:17 UTC 2023


Hi,

On Sunday, 26 March 2023 16:06:04 IST Dmitry V. Levin wrote:
> On Sun, Mar 26, 2023 at 03:57:24PM +0530, Sahil Siddiq wrote:
> > Hi,
> > 
> > Thank you for the feedback. There are a few things that I haven't
> > really understood.
> > 
> > On Sunday, 26 March 2023 01:11:07 IST Dmitry V. Levin wrote:
> > > On Mon, Mar 20, 2023 at 11:10:56AM +0530, Sahil Siddiq wrote:
> > > [...]
> > > for example, a tracee
> > > doesn't invoke syscalls, strace -l won't finish.
> > 
> > I didn't understand this example. In case the argument to -l is greater
> > than the number of syscalls that are invoked, wouldn't strace proceed
> > as usual? If the tracee does not invoke any syscall, the syscall_limit
> > counter will not decrease in syscall_exiting_trace().
> 
> Here is an example: take your strace--syscall-limit.c test, insert sleep(60)
> right before the waitpid loop, and see what happens.

I am still a bit confused. I inserted sleep(60) so that the test snippet now looks
like this:

        sleep(60);
        while ((waitpid(child, &status, 0)) != child) {
                if (errno == EINTR)
                        continue;
                perror_msg_and_fail("waitpid: %d", child);
        }

I first ran the following command:

strace --signal='!SIGCHLD,SIGCONT' --quiet=path-resolution -f -a 9 --trace=chdir,getpid --syscall-limit=3 ./strace--syscall-limit

This gives the same output that I would expect. It prints only the first three syscalls
that were traced along with the "process <pid> attached/detached" log lines and it
terminates after that.

However, when running "bash ./strace--syscall-limit.test", the test indeed does not
terminate.

Running "ps f" gives the following output:

  11441 pts/2    Ss     0:00 /bin/bash
254572 pts/2    S+     0:00  \_ bash ./strace--syscall-limit.test
254648 pts/2    S+     0:00      \_ ../../src/strace -o log --signal=!SIGCHLD,SIGCONT --quiet=path-resolution -f -a 9 --trace=chdir,getpid --syscall-limit=3
254651 pts/2    S+     0:00          \_ ../strace--syscall-limit
254652 pts/2    Z+     0:00              \_ [strace--syscall] <defunct>

I wonder why this is the case. I'll try to figure this out.

Regards,
Sahil




More information about the Strace-devel mailing list