Hello,
Distro : Debian 10 - 64bits
I think it's the right list ; if not, please redirect me.
In order to launch a command from within the C programme in
attachment, I use "fork - execve - wait" trio so that parent
program waits until command has finished
Building the program : cc execve.c -o execve
Program syntax : ./execve <command full path>
Example : ./execve /usr/bin/gvim
The problem :
--- if I execute "./execve /usr/bin/gvim", gvim starts after a few seconds but without executing .vimrc, and parent program doesn't wait for gvim to end.
Output of "ps -auwx --forest" during the few wait seconds :
lgentis 5216 0.0 0.0 7124 3812 pts/0 Ss 14:47
0:00 \_ bash
lgentis 9368 0.0 0.0 2144 752 pts/0 S+ 16:44
0:00 | \_ ./execve /usr/bin/gvim
lgentis 9369 2.0 0.2 68916 16452 pts/0 S+ 16:44 0:00
| \_ gvim
lgentis 9392 2.5 0.3 71620 22444 ? Ss 16:44
0:00 | \_ gvim
Output of "ps -auwx --forest" once gvim started :
lgentis 5212 0.1 0.7 426212 43880 ? Rl 14:47 0:07 xfce4-terminalWe can see that gvim is not a child process of the parent
program (which has ended)
--- if I execute "./execve /usr/bin/vim.gtk", vim starts in text mode in the console ; however, parent program waits till vim is closed.
Output of "ps -auwx --forest" :
lgentis 5212 0.0 0.7 426212 43880 ? Rl 14:47
0:06 xfce4-terminal
lgentis 5216 0.0 0.0 7124 3812 pts/0 Ss 14:47
0:00 \_ bash
lgentis 9011 0.0 0.0 2144 748 pts/0 S+ 16:34
0:00 | \_ ./execve /usr/bin/vim.gtk
lgentis 9012 0.8 0.2 68932 17232 pts/0 S+ 16:34 0:00
| \_ vim.gtk
We can see that vim.gtk is a child process of the parent program
--- I did the same test with gedit and audacious, and all works
fine : child program is executed and parent program waits as
expected.
Output of "ps -auwx --forest" :
lgentis 5212 0.0 0.7 425664 43548 ? Sl 14:47
0:05 xfce4-terminal
lgentis 5216 0.0 0.0 7124 3812 pts/0 Ss 14:47
0:00 \_ bash
lgentis 8910 0.0 0.0 2144 748 pts/0 S+ 16:30
0:00 | \_ ./execve /usr/bin/gedit
lgentis 8911 4.2 0.7 477720 47812 pts/0 Sl+ 16:30 0:00
| \_ gedit
We can see that gedit is a child process of the parent program