visionmedia/mon — pull request #17 by flexd (2012-12-07 11:55:05+00:00)
Title: Pass the PID (and other information?) to the on-error script/program executed.

I made the on-error command pass along the PID of the failing process, even if that isn't really useful.
It's more of a suggestion than an actual pull-request, mainly because I have very little knowledge of C++ and this is probably done in a bad way! :) It does work fine though.

```bash
kristoffer@dev:~/code/mon$ ./mon "echo hello" --attempts 3 --on-error "echo $1 hello"
mon : child 6674
mon : sh -c "echo hello"
hello
mon : last restart less than one second ago
mon : 3 attempts remaining
mon : child 6675
mon : sh -c "echo hello"
hello
mon : last restart less than one second ago
mon : 2 attempts remaining
mon : child 6676
mon : sh -c "echo hello"
hello
mon : last restart less than one second ago
mon : 1 attempts remaining
mon : 3 restarts within less than one second, bailing
mon : on error `echo hello 6676`
hello 6676
mon : bye :)
```

I have also added the on-error argument to mongroup, so we can have some basic error reporting there. Since mon only really knows the PID, it might be better to have mongroup pass in the command + some arguments of its own with process-name or something like that to be able to get more detailed information into the error-reporting emails (or other error logging processes).

Anyway, I hope this is useful and that someone else agrees with my suggestion!