[PATCH] [main] Write the pid of plymouthd to a file

Ray Strode halfline at gmail.com
Tue Mar 2 11:20:36 PST 2010


Hi,

On Tue, Mar 2, 2010 at 11:38 AM, Scott James Remnant <scott at ubuntu.com> wrote:
> Add a --pid-file option to plymouthd that will cause the daemon's
> pid to be written to the named file.  Useful to avoid grovelling
> through ps output to find it again.
In principle seems fine.  I have few comments below:

> --- a/src/libply/ply-utils.c
> +++ b/src/libply/ply-utils.c
> @@ -820,6 +820,22 @@ ply_create_daemon (void)
>           _exit (1);
>         }
>
> +      if ((byte == 0) && (pid_file != NULL))
> +        {
> +         FILE *pidf;
> +
> +         pidf = fopen (pid_file, "w");
> +         if (!pidf)
> +           {
> +             ply_error ("could not write pid file %s: %m", pid_file);
> +           }
> +         else
> +           {
> +             fprintf (pidf, "%d\n", pid);
Since pid is type pid_t, this should probably have a (int) cast.

> +void
> +ply_remove_pid_file (const char *pid_file)
> +{
> +  if (ply_file_exists (pid_file))
> +    unlink (pid_file);
> +}
> +
This function isn't really useful.  It would be better to drop
the ply_file_exists entirely and unconditionally call unlink() where
ply_remove_pid_file is called.

> +static char *pid_file = NULL;
This should probably go in the state_t structure with the other state.

--Ray


More information about the plymouth mailing list