[PATCH] chg: exec pager in child process

Yuya Nishihara yuya at tcha.org
Sun Jun 12 10:07:01 EDT 2016


On Sat, 11 Jun 2016 20:27:07 +0100, Jun Wu wrote:
> # HG changeset patch
> # User Jun Wu <quark at fb.com>
> # Date 1465673149 -3600
> #      Sat Jun 11 20:25:49 2016 +0100
> # Node ID 1b3b0aae1d814f7b202d7d1c52132ac7d0202989
> # Parent  c27dc3c31222c7f74331221a3d25566146feecac
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r 1b3b0aae1d81
> chg: exec pager in child process

Looks mostly good to me. A few nits.

> -/* This implementation is based on hgext/pager.py (pre 369741ef7253) */
> -static void setuppager(hgclient_t *hgc, const char *const args[],
> +/* This implementation is based on hgext/pager.py (pre 369741ef7253)
> + * Return 0 if pager is not started, or pid of the pager */

So this is basically the post-369741ef7253 pager. Can you remove (or update)
the outdated comment?

And yes, test-pager.t is better place to write the test.

> +static void waitpager(pid_t pid)
> +{
> +	/* close output streams to notify the pager its input ends */
> +	fclose(stdout);
> +	fclose(stderr);
> +	while (1) {
> +		int stat = 0;
> +		pid_t ret = waitpid(pid, &stat, 0);
> +		if (ret == -1) {
> +			if (errno == EINTR)
> +				continue;
> +			break;
> +		}
> +		if (WIFEXITED(stat) || WIFSIGNALED(stat))
> +			break;

waitpid() does not return on stopped/continued by default, so we won't need
to check the status.


More information about the Mercurial-devel mailing list