fork() and exec() instead of system()
fixed pid writing order