[PATCH 2 of 2] chg: send SIGPIPE to server immediately when pager exits (issue5278)

Yuya Nishihara yuya at tcha.org
Tue Jun 28 09:15:36 EDT 2016


On Fri, 24 Jun 2016 17:10:18 +0100, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark at fb.com>
> # Date 1466778070 -3600
> #      Fri Jun 24 15:21:10 2016 +0100
> # Node ID 701ec0855d2c4b9a40aeb3c8d317aa6b54a3e308
> # Parent  f1195d649b4237400de44ac741f701aded61eb95
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r 701ec0855d2c
> chg: send SIGPIPE to server immediately when pager exits (issue5278)

Queued these, thanks.

> +static void handlechildsignal(int sig)
> +{
> +	if (peerpid == 0 || pagerpid == 0)
> +		return;
> +	/* if pager exits, notify the server with SIGPIPE immediately.
> +	 * otherwise the server won't get SIGPIPE if it does not write
> +	 * anything. (issue5278) */
> +	if (waitpid(pagerpid, NULL, WNOHANG) == pagerpid)
> +		kill(peerpid, SIGPIPE);
> +}
> +
>  static void setupsignalhandler(pid_t pid)
>  {
>  	if (pid <= 0)
> @@ -416,6 +428,11 @@ static void setupsignalhandler(pid_t pid
>  	sa.sa_flags = SA_RESTART;
>  	if (sigaction(SIGTSTP, &sa, NULL) < 0)
>  		goto error;
> +	/* get notified when pager exits */
> +	sa.sa_handler = handlechildsignal;
> +	sa.sa_flags = SA_RESTART;
> +	if (sigaction(SIGCHLD, &sa, NULL) < 0)
> +		goto error;

I've updated restoresignalhandler() accordingly thought it isn't necessary.


More information about the Mercurial-devel mailing list