0

I tried running the command

strace -f gnome-terminal --wait |& grep write

and then in the terminal window that opened, I typed ls and pressed enter.

I expected to see write syscalls corresponding to the l, s, \n characters getting sent to the Bash child process running inside the terminal as well write syscalls when the ls child-child process wrote its output, but instead I didn't see any syscalls happening when I ran ls.

I do see these write syscalls when I run

strace -f xterm |& grep write

Why does strace -f fail to follow the child processes of gnome-terminal?

3
  • Not an answer to your question but a workaround for attaching the process. Since gnome terminal seems to work different you can attach the shell instead of the terminal. When gnome terminal is opened you should use echo $$ to get the pid of the current shell and attach this one by using: sudo strace -fp thepid (you might need to use sudo , otherwise you'll get operation not permitted) Commented Dec 30, 2022 at 5:09
  • 1
    The actual gnome-terminal-server that's doing the terminal emulation isn't a descendant of the gnome-terminal command you launch. gnome-terminal starts up gnome-terminal-server via some systemd / dbus or similar magic (which I'm not familiar with). You can figure out gnome-terminal-server's PID and attach to it via strace -p PID. Note that if you have multiple gnome-terminal tabs or windows, this will trace all of them. Commented Dec 30, 2022 at 19:28
  • @egmont if you write up your comment as an answer I would accept it :) Commented Dec 31, 2022 at 20:03

1 Answer 1

0

The actual gnome-terminal-server that's doing the terminal emulation isn't a descendant of the gnome-terminal command you launch. gnome-terminal starts up gnome-terminal-server via some systemd / dbus or similar magic (which I'm not familiar with), i.e. asks an already running service to launch the terminal.

You can figure out gnome-terminal-server's PID and attach to it using strace -p PID. Note that if you have multiple gnome-terminal tabs or windows, this will trace all of them.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.