Re: [PATCH] compat/mingw: stubs for getpgid() and tcgetpgrp()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Johannes Sixt <j6t@xxxxxxxx> writes:

> Windows does not have process groups. It is, therefore, the simplest
> to pretend that each process is in its own process group.
>
> While here, move the getppid() stub from its old location (between
> two sync related functions) next to the two new functions.
>
> Signed-off-by: Johannes Sixt <j6t@xxxxxxxx>
> ---

Thanks for a quick update.

The patch should do for now, but I suspect that it may give us a
better abstraction to make the "is_foreground_fd(int fd)" or even
"is_foreground(void)" the public API that would be implemented as

	int we_are_in_the_foreground(void)
        {
		return getpgid(0) == tcgetpgrp(fileno(stderr));
	}

in POSIX and Windows can implement entirely differently.

Thoughts?

>  compat/mingw.h | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/compat/mingw.h b/compat/mingw.h
> index 7b523cf..a552026 100644
> --- a/compat/mingw.h
> +++ b/compat/mingw.h
> @@ -95,8 +95,6 @@ static inline unsigned int alarm(unsigned int seconds)
>  { return 0; }
>  static inline int fsync(int fd)
>  { return _commit(fd); }
> -static inline pid_t getppid(void)
> -{ return 1; }
>  static inline void sync(void)
>  {}
>  static inline uid_t getuid(void)
> @@ -118,6 +116,12 @@ static inline int sigaddset(sigset_t *set, int signum)
>  #define SIG_UNBLOCK 0
>  static inline int sigprocmask(int how, const sigset_t *set, sigset_t *oldset)
>  { return 0; }
> +static inline pid_t getppid(void)
> +{ return 1; }
> +static inline pid_t getpgid(pid_t pid)
> +{ return pid == 0 ? getpid() : pid; }
> +static inline pid_t tcgetpgrp(int fd)
> +{ return getpid(); }
>  
>  /*
>   * simple adaptors
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]