Search code examples
linuxexecforkqemutty

QEMU no terminal output after execvp


QEMU is used by me as an emulator with PetaLinux kernel (terminal-only with -nographic option).

At the beginning QEMU initializes itself and once it's ready it boots-up the system. Usually, boot messages are printed in a terminal during the process. With that scenario everything works fine, system starts and one can login and use the system. Then, another simple peripheral device is implemented, which similarly is initialized (printing control message to the output) and the rest goes on the same way.

The problem rises when there is a child process spawned from inside the peripheral implementation ( fork() followed by execvp() ). The main QEMU process (parent) no longer prints to the terminal output, the new process (child) only can do it. It seems like the parent process is probably still executing but loses the terminal. Without it one cannot see login prompt, so basically cannot use the system at all.

What is the reason?


Solution

  • I found the solution. The problem was because the child process was using SIGUSR1 to signal some event to the parent process. Apparently, QEMU itself uses SIGUSR1 so there was a collision of handlers, maybe both of them had been invoked, and somehow the parent process was freezing. Everything works fine after changing my signal to SIGUSR2. Hopefully there is no more collision with QEMU internals.