MSYS2-packages/procps-ng/procps-ng-3.3.17-ctty.patch
Biswapriyo Nath 2b6756f211 procps-ng: Update to 3.3.17
* Add pgp key.
* Import patches from cygwin.
* Add check function.
2021-11-30 15:19:43 +05:30

54 lines
1.8 KiB
Diff

--- a/configure.ac
+++ b/configure.ac
@@ -85,8 +85,12 @@
usrbin_execdir='${exec_prefix}/bin'
AC_SUBST([usrbin_execdir])
+AC_DEFINE([USE_PROC_CTTY], [0], [Use /proc/$PID/ctty to determine controlling TTY])
+AC_DEFINE([USE_SYS_SYSMACROS_H], [0], [Use "sys/sysmacros.h" to determine major/minor device numbers])
if test "x$host_os" = xcygwin
then
+ AC_DEFINE([USE_PROC_CTTY], [1], [Use /proc/$PID/ctty to determine controlling TTY])
+ AC_DEFINE([USE_SYS_SYSMACROS_H], [1], [Use "sys/sysmacros.h" to determine major/minor device numbers])
prefix=/usr
sysconfdir=/etc
libexecdir=/usr/lib
--- a/proc/devname.c
+++ b/proc/devname.c
@@ -40,7 +40,7 @@
* dev_to_tty top, ps
*/
-#if 0
+#ifdef USE_SYS_SYSMACROS_H
#include <sys/sysmacros.h>
#define MAJOR_OF(d) ((unsigned)major(d))
#define MINOR_OF(d) ((unsigned)minor(d))
@@ -212,7 +212,7 @@
case 3: /* /dev/[pt]ty[p-za-o][0-9a-z] is 936 */
if(tmpmin > 255) return 0; // should never happen; array index protection
#ifdef __CYGWIN__
- sprintf(buf, "dev/cons%d", tmpmin);
+ sprintf(buf, "cons%d", tmpmin);
/* Skip stat call. The reason is that cons devices are local to
the processes running in that console. Calling stat from another
console or pty will return -1. */
@@ -300,7 +300,7 @@
return 1;
}
-#ifdef __CYGWIN__
+#ifdef USE_PROC_CTTY
/* Cygwin keeps the name to the controlling tty in a virtual file called
/proc/PID/ctty, including a trailing LF (sigh). */
static int ctty_name(char *restrict const buf, int pid) {
@@ -332,7 +332,7 @@
unsigned i = 0;
int c;
if(dev == 0u) goto no_tty;
-#ifdef __CYGWIN__
+#ifdef USE_PROC_CTTY
if( ctty_name(tmp, pid )) goto abbrev;
#endif
if(driver_name(tmp, MAJOR_OF(dev), MINOR_OF(dev) )) goto abbrev;