I tried to execute a process using something like the following:
system("zsh &");
I don't think it works though, because the process doesn't show up. Why doesn't it work? How should it be changed?
I tried to execute a process using something like the following:
system("zsh &");
I don't think it works though, because the process doesn't show up. Why doesn't it work? How should it be changed?
Regardless of any ampersand to run it in the background, or what system() will do, you're launching an interactive shell. When you launch an interactive shell, it looks for a console to connect to, Failing that, it looks for stdin lines to process. Failing that, it exits. That's what's happening.
Following code works perfectly, using htop I can see that sleep is still running after my app terminates. I don't see how it should be different in your code.
#include <stdio.h>
int main()
{
return system("sleep 100 &");
}
It's because zsh and all shells bind stdin and it couldn't on background so it crashed. That's also why sleep in background worked.