Patchwork qemu-ga: ga_open_pidfile(): add new line to pidfile

login
register
mail settings
Submitter Luiz Capitulino
Date Oct. 3, 2012, 5:25 p.m.
Message ID <20121003142541.1d5b998d@doriath.home>
Download mbox | patch
Permalink /patch/188862/
State New
Headers show

Comments

Luiz Capitulino - Oct. 3, 2012, 5:25 p.m.
FHS dictates that pid files should end with a new line.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 qemu-ga.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Blue Swirl - Oct. 3, 2012, 8:24 p.m.
On Wed, Oct 3, 2012 at 5:25 PM, Luiz Capitulino <lcapitulino@redhat.com> wrote:
> FHS dictates that pid files should end with a new line.
>
> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
> ---
>  qemu-ga.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/qemu-ga.c b/qemu-ga.c
> index b747470..afd685e 100644
> --- a/qemu-ga.c
> +++ b/qemu-ga.c
> @@ -255,7 +255,7 @@ static bool ga_open_pidfile(const char *pidfile)
>          g_critical("Failed to truncate pid file");
>          goto fail;
>      }
> -    sprintf(pidstr, "%d", getpid());
> +    sprintf(pidstr, "%d\n", getpid());

Please convert to snprintf() while at it.

>      if (write(pidfd, pidstr, strlen(pidstr)) != strlen(pidstr)) {
>          g_critical("Failed to write pid file");
>          goto fail;
> --
> 1.7.12.315.g682ce8b
>
>

Patch

diff --git a/qemu-ga.c b/qemu-ga.c
index b747470..afd685e 100644
--- a/qemu-ga.c
+++ b/qemu-ga.c
@@ -255,7 +255,7 @@  static bool ga_open_pidfile(const char *pidfile)
         g_critical("Failed to truncate pid file");
         goto fail;
     }
-    sprintf(pidstr, "%d", getpid());
+    sprintf(pidstr, "%d\n", getpid());
     if (write(pidfd, pidstr, strlen(pidstr)) != strlen(pidstr)) {
         g_critical("Failed to write pid file");
         goto fail;