[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] Re: [RFC][PATCH v7 15/16] virtagent: qemu-va, system-level
From: |
Jes Sorensen |
Subject: |
[Qemu-devel] Re: [RFC][PATCH v7 15/16] virtagent: qemu-va, system-level virtagent guest agent |
Date: |
Wed, 09 Mar 2011 11:48:51 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Thunderbird/3.1.7 |
On 03/07/11 21:10, Michael Roth wrote:
> Signed-off-by: Michael Roth <address@hidden>
> ---
> qemu-va.c | 247
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 247 insertions(+), 0 deletions(-)
> create mode 100644 qemu-va.c
>
> diff --git a/qemu-va.c b/qemu-va.c
> new file mode 100644
> index 0000000..a9ff56f
> --- /dev/null
> +++ b/qemu-va.c
> @@ -0,0 +1,247 @@
[snip]
> +static void become_daemon(void)
> +{
> + pid_t pid, sid;
> + int pidfd;
> + char *pidstr;
> +
> + pid = fork();
> + if (pid < 0)
> + exit(EXIT_FAILURE);
> + if (pid > 0) {
> + exit(EXIT_SUCCESS);
> + }
> +
> + pidfd = open(VA_PIDFILE, O_CREAT|O_RDWR, S_IRUSR|S_IWUSR);
> + if (!pidfd || lockf(pidfd, F_TLOCK, 0))
> + errx(EXIT_FAILURE, "Cannot lock pid file");
> +
> + if (ftruncate(pidfd, 0) || lseek(pidfd, 0, SEEK_SET))
> + errx(EXIT_FAILURE, "Cannot truncate pid file");
> + if (asprintf(&pidstr, "%d", getpid()) == -1)
> + errx(EXIT_FAILURE, "Cannot allocate memory");
> + if (write(pidfd, pidstr, strlen(pidstr)) != strlen(pidstr))
> + errx(EXIT_FAILURE, "Failed to write pid file");
> + free(pidstr);
Coding style - this needs to be fixed.
> + umask(0);
> + sid = setsid();
> + if (sid < 0)
> + goto fail;
> + if ((chdir("/")) < 0)
> + goto fail;
and again
Cheers,
Jes
- Re: [Qemu-devel] Re: [RFC][PATCH v7 01/16] Move code related to fd handlers into utility functions, (continued)
[Qemu-devel] Re: [RFC][PATCH v7 01/16] Move code related to fd handlers into utility functions, Paolo Bonzini, 2011/03/09
[Qemu-devel] [RFC][PATCH v7 06/16] virtagent: transport definitions, Michael Roth, 2011/03/07
[Qemu-devel] [RFC][PATCH v7 13/16] virtagent: add va_shutdown HMP/QMP command, Michael Roth, 2011/03/07
[Qemu-devel] [RFC][PATCH v7 11/16] virtagent: add va_ping HMP/QMP command, Michael Roth, 2011/03/07
[Qemu-devel] [RFC][PATCH v7 15/16] virtagent: qemu-va, system-level virtagent guest agent, Michael Roth, 2011/03/07
- [Qemu-devel] Re: [RFC][PATCH v7 15/16] virtagent: qemu-va, system-level virtagent guest agent,
Jes Sorensen <=
[Qemu-devel] [RFC][PATCH v7 16/16] virtagent: add bits to build virtagent host/guest components, Michael Roth, 2011/03/07
[Qemu-devel] [RFC][PATCH v7 12/16] virtagent: add "shutdown" RPC to server, Michael Roth, 2011/03/07
[Qemu-devel] [RFC][PATCH v7 14/16] virtagent: add virtagent chardev, Michael Roth, 2011/03/07
[Qemu-devel] [RFC][PATCH v7 07/16] virtagent: base RPC client definitions, Michael Roth, 2011/03/07
[Qemu-devel] [RFC][PATCH v7 08/16] virtagnet: base RPC server definitions, Michael Roth, 2011/03/07
[Qemu-devel] [RFC][PATCH v7 04/16] virtagent: bi-directional RPC handling logic, Michael Roth, 2011/03/07
[Qemu-devel] [RFC][PATCH v7 05/16] virtagent: common helpers and init routines, Michael Roth, 2011/03/07