From the specification those two lines in the child's code
glob++;
var++;
provoke undefined behaviuor.
From Linux man vfork
:
(From POSIX.1) [...] the behavior is undefined if the process created by vfork() either modifies any data other than a variable of type pid_t used to store the return value from vfork() [...]
It might be worth noting that vfork()
was "marked obsolescent" in the previous version of POSIX (see POSIX link above) and was removed from POSIX with Issue 7 (POSIX.1-2008):
Applications are recommended to use the fork() function instead of this function.
The vfork() function was previously under-specified.