[PATCH] Add --foreground option for nscd
Pedro Alves
palves@redhat.com
Wed May 9 15:24:00 GMT 2012
On 05/09/2012 03:33 PM, Andreas Jaeger wrote:
> int disabled_group;
> -int go_background = 1;
> +
> +enum
> +{
> + /* Running in foreground but otherwise behave like a daemon,
> + i.e., detach from terminal and use syslog. */
> + RUN_FOREGROUND,
> + /* Running in background as daemon. */
> + RUN_DAEMONIZE,
> + /* Run in foreground in debug mode. */
> + RUN_DEBUG
> +};
> +static int run_mode = RUN_DAEMONIZE;
Since you have an enum, why not make the variable have enum type too?
If you don't want to give the enum a name/tag, there's always:
static enum
{
...
} run_mode = RUN_DAEMONIZE;
As principle, making the type an enum makes the code easier to debug,
as "(gdb) print run_mode" then outputs the enum value (RUN_DAEMONIZE, etc.)
instead of the underlying integer (0, 1, etc.).
> - /* Behave like a daemon. */
> - if (go_background)
> + if ((run_mode == RUN_DAEMONIZE) || (run_mode == RUN_FOREGROUND))
GNU style is against such redundant parenthesis.
--
Pedro Alves
More information about the Libc-alpha
mailing list