Hijack arg when opening /dev or /proc to avoid TOCTTOU problems

If we don't hijack the arg when opening /dev or /proc paths, an other
thread could overwrite it after the check.