[CRIU] [PATCH] crtools: write pidfile, when service server is run as daemon and "--pidfile" is set

Pavel Emelyanov xemul at parallels.com
Sun Sep 15 16:32:20 EDT 2013


On 09/15/2013 09:06 PM, Ruslan Kuprieiev wrote:
> Hi!
> 
> When service server becomes daemon, we may need to know it's pid.
> 
> Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
> 


> @@ -218,12 +218,19 @@ int cr_service(bool daemon_mode)
>  	}
>  
>  	if (daemon_mode) {
> -		if (daemon(0, 0) == -1) {
> +		if (daemon(1, 1) == -1) {
>  			pr_perror("Can't run service server in the background");
>  			return -errno;
>  		}
>  	}
>  
> +	if (opts.pidfile) {
> +		if (write_pidfile(opts.pidfile, getpid()) == -1) {
> +			pr_perror("Can't write pidfile");
> +			return -1;
> +		}
> +	}
> +
>  	/* FIXME Do not ignore children's return values */
>  	signal(SIGCHLD, SIG_IGN);
>  

Add the same call to page-server.


More information about the CRIU mailing list