It works !
just doing a few more modifications and I will commit.
the problems were : 
1 - the script was launched via a shell script, and the pid kept in the pid file was the sh pid.
2 - minerd was launch in background, so the parent process was killed after the childs processes were forked.