On 12/26/23, Greg Wooledge <g...@wooledge.org> wrote: > On Tue, Dec 26, 2023 at 02:57:54PM +0000, Albretch Mueller wrote: >> 1) how do you set up the process to be straced as a parameter? Something >> like: >> prx="echo hello" >> logfile="file.txt" >> # >> strace "${prx}" 2>"${logfile}" >> ls -l "${logfile}"; wc -l "${logfile}"; cat "${logfile}" > > Why? This does not appear to have any usefulness. You're just making > your life harder for no reason.
Well, the way I see such my options, you could: 1.1) parametrize a call to a function, or 1.2) use named files for each type of strace run. I would rather use ยง1.1 > See also <https://mywiki.wooledge.org/BashFAQ/050>. Thank you. As you have suggested to me. I will have to use a highlevel language if I want to take care of my "coblesome" cases. I tend to entangle myself in corner cases for which scripts aren't so useful. >> 2) how do you know for sure that you are stracing the same process >> that you are running and is logging some data? > > You are EXTREMELY confused about something, and we NEED to address this > immediately. > > If you run "strace ./foo", a new instance of ./foo is launched right > then and there, and you get the system call trace of THAT instance. Based on: https://askubuntu.com/questions/137233/how-to-command-ping-display-time-and-date-of-ping/867500 I think I am getting close to where I need to with this (am I?): $ bash -c 'ping www.google.fr -c 4 &'; echo "Caller PID: $$"; strace -p $$ Caller PID: 45588 strace: Process 45588 attached wait4(-1, PING www.google.fr (142.250.190.131) 56(84) bytes of data. 64 bytes from ord37s36-in-f3.1e100.net (142.250.190.131): icmp_seq=1 ttl=54 time=50.0 ms 64 bytes from ord37s36-in-f3.1e100.net (142.250.190.131): icmp_seq=2 ttl=54 time=34.7 ms 64 bytes from ord37s36-in-f3.1e100.net (142.250.190.131): icmp_seq=3 ttl=54 time=38.7 ms 64 bytes from ord37s36-in-f3.1e100.net (142.250.190.131): icmp_seq=4 ttl=54 time=40.3 ms --- www.google.fr ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3004ms rtt min/avg/max/mdev = 34.735/40.952/50.048/5.628 ms ^Cstrace: Process 45588 detached <detached ...> $ However, strace doesn't end gracefully even though it seems to attach to the running process before it starts and based on what strace itself logs, the process seems to end just fine.