cli.php uses for now a simple behaviour:
- If a task thrown an uncaught exception, status code will be 1
- Else, it will be 0
All symfony 1.1 task mechanism pass return value to its caller though, only cli.php just throw it to dust.
sfTask::doRun() passes it to sfTask::runFromCLI() that gives it to sfSymfonyCommandApplication::run(), which sends it to sf_lib_dir/command/cli.php which just ignore it.
The behaviour can be enhanced to keep this default behaviour if no return value (or non numeric) is given, or if the thrown exception does not provide a custom exception code, but use the custom value otherwise. That allows to create advanced task interaction/communication between symfony tasks and other processes (c, shell script, whatever...) and allows better control on how a symfony task process finished.
I attach a simple patch to do so