Commit d02da404 authored by Wayne Porter's avatar Wayne Porter

Merge branch 'v3.3.10-cygwin'

parents 5dcbcd00 ed22eb87
Pipeline #1333198 passed with stage
CYGWINFLAGS =
if CYGWIN
CYGWINFLAGS += -lintl
CYGWINFLAGS += -lintl
usrbin_exec_PROGRAMS =
endif
AM_CPPFLAGS = \
......@@ -19,10 +20,20 @@ SUBDIRS = \
testsuite
AM_CFLAGS = -Iproc
AM_LDFLAGS = ./proc/libprocps.la $(CYGWINFLAGS)
LDADD = ./proc/libprocps.la $(CYGWINFLAGS)
transform = s/pscommand/ps/; $(program_transform_name)
transform =
if !CYGWIN
transform += s/pscommand/ps/; $(program_transform_name)
sbin_PROGRAMS = \
sysctl
else
transform += s/pscommand/procps/; $(program_transform_name)
endif
if !CYGWIN
bin_PROGRAMS = \
ps/pscommand \
free \
......@@ -34,9 +45,19 @@ bin_PROGRAMS = \
uptime \
vmstat \
w
sbin_PROGRAMS = \
sysctl
else
usrbin_exec_PROGRAMS += \
ps/pscommand \
free \
pgrep \
pkill \
pmap \
pwdx \
tload \
uptime \
vmstat \
w
endif
lib_LTLIBRARIES = \
proc/libprocps.la
......@@ -47,14 +68,18 @@ dist_man_MANS = \
pkill.1 \
pmap.1 \
pwdx.1 \
sysctl.8 \
sysctl.conf.5 \
tload.1 \
uptime.1 \
vmstat.8 \
w.1 \
ps/ps.1
if !CYGWIN
dist_man_MANS += \
tload.1 \
sysctl.8 \
sysctl.conf.5
endif
EXTRA_DIST = \
.version \
autogen.sh \
......@@ -63,7 +88,6 @@ EXTRA_DIST = \
misc/git-version-gen \
Documentation/CodingStyle.md \
Documentation/TODO \
sysctl.conf \
ps/HACKING \
ps/regression \
$(DIST_MAN_POTS)
......@@ -73,8 +97,17 @@ dist_procpsng_DATA = \
Documentation/bugs.md \
Documentation/FAQ
if !CYGWIN
EXTRA_DIST += \
sysctl.conf
endif
if BUILD_PIDOF
if !CYGWIN
bin_PROGRAMS += pidof
else
usrbin_exec_PROGRAMS += pidof
endif
dist_man_MANS += pidof.1
pidof_SOURCES = pidof.c lib/fileutils.c
else
......@@ -82,7 +115,13 @@ else
endif
if BUILD_KILL
if CYGWIN
transform += s/^kill/prockill/; $(program_transform_name)
usrbin_exec_PROGRAMS += kill
else
bin_PROGRAMS += kill
endif
dist_man_MANS += kill.1
kill_SOURCES = skill.c lib/strutils.c lib/fileutils.c lib/nsutils.c
else
......@@ -90,16 +129,20 @@ else
endif
if WITH_NCURSES
if !CYGWIN
bin_PROGRAMS += \
slabtop \
watch \
top/top
else
usrbin_exec_PROGRAMS += \
watch \
top/top
endif
dist_man_MANS += \
slabtop.1 \
watch.1 \
top/top.1
slabtop_SOURCES = slabtop.c lib/strutils.c lib/fileutils.c
slabtop_LDADD = $(LDADD) @NCURSES_LIBS@
watch_SOURCES = watch.c lib/strutils.c lib/fileutils.c
watch_LDADD = @WATCH_NCURSES_LIBS@ $(CYGWINFLAGS)
top_top_SOURCES = \
......@@ -108,17 +151,29 @@ top_top_SOURCES = \
top/top_nls.h \
top/top_nls.c \
lib/fileutils.c
if CYGWIN
top_top_SOURCES += lib/strverscmp.c
top_top_SOURCES += lib/strverscmp.c
else
dist_man_MANS += \
slabtop.1
slabtop_SOURCES = slabtop.c lib/strutils.c lib/fileutils.c
slabtop_LDADD = $(LDADD) @NCURSES_LIBS@
endif
top_top_LDADD = $(LDADD) @NCURSES_LIBS@ $(DL_LIB)
endif
if BUILD_SKILL
if !CYGWIN
bin_PROGRAMS += \
skill \
snice
else
usrbin_exec_PROGRAMS += \
skill \
snice
endif
skill_SOURCES = skill.c lib/strutils.c lib/fileutils.c lib/nsutils.c
snice_SOURCES = skill.c lib/strutils.c lib/fileutils.c lib/nsutils.c
dist_man_MANS += \
......@@ -130,13 +185,15 @@ else
snice.1
endif
free_SOURCES = free.c lib/strutils.c lib/fileutils.c
free_SOURCES = free.c lib/strutils.c lib/fileutils.c
pgrep_SOURCES = pgrep.c lib/fileutils.c lib/nsutils.c
pkill_SOURCES = pgrep.c lib/fileutils.c lib/nsutils.c
pmap_SOURCES = pmap.c lib/fileutils.c
pwdx_SOURCES = pwdx.c lib/fileutils.c
pwdx_LDADD= $(CYGWINFLAGS)
if !CYGWIN
sysctl_SOURCES = sysctl.c lib/fileutils.c
endif
tload_SOURCES = tload.c lib/strutils.c lib/fileutils.c
uptime_SOURCES = uptime.c lib/fileutils.c
vmstat_SOURCES = vmstat.c lib/strutils.c lib/fileutils.c
......@@ -248,9 +305,24 @@ lib_test_process_LDADD = $(CYGWINFLAGS)
lib_test_strtod_nol_SOURCES = lib/test_strtod_nol.c lib/strutils.c
lib_test_strtod_nol_LDADD = $(CYGWINFLAGS)
skill_LDADD = $(CYGWINFLAGS)
kill_LDADD = $(CYGWINFLAGS)
free_LDADD = $(CYGWINFLAGS)
pgrep_LDADD = $(CYGWINFLAGS)
pkill_LDADD = $(CYGWINFLAGS)
pidof_LDADD = $(CYGWINFLAGS)
pmap_LDADD = $(CYGWINFLAGS)
snice_LDADD = $(CYGWINFLAGS)
tload_LDADD = $(CYGWINFLAGS)
uptime_LDADD = $(CYGWINFLAGS)
w_LDADD = $(CYGWINFLAGS)
vmstat_LDADD = $(CYGWINFLAGS)
if EXAMPLE_FILES
if !CYGWIN
sysconf_DATA = sysctl.conf
endif
endif
BUILT_SOURCES = $(top_srcdir)/.version
......
......@@ -69,6 +69,13 @@ AC_FUNC_MMAP
AC_FUNC_REALLOC
AC_FUNC_STRTOD
if test "x$host_os" = xcygwin; then
usrbin_execdir='${exec_prefix}/bin'
else
usrbin_execdir='${exec_prefix}/usr/bin'
fi
AC_SUBST([usrbin_execdir])
AM_GNU_GETTEXT_VERSION([0.14.1])
AM_GNU_GETTEXT([external])
if test -d "$srcdir/po"
......
......@@ -200,15 +200,25 @@ int main(int argc, char *argv[]){
/* Try to guess the device name (useful until /proc/PID/tty is added) */
static int guess_name(char *restrict const buf, unsigned maj, unsigned min){
struct stat sbuf;
#ifndef __CYGWIN__
int t0, t1;
#endif
unsigned tmpmin = min;
switch(maj){
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);
/* 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. */
return 1;
#else
t0 = "pqrstuvwxyzabcde"[tmpmin>>4];
t1 = "0123456789abcdef"[tmpmin&0x0f];
sprintf(buf, "/dev/tty%c%c", t0, t1);
#endif
break;
case 4:
if(min<64){
......@@ -233,8 +243,12 @@ static int guess_name(char *restrict const buf, unsigned maj, unsigned min){
case 78: sprintf(buf, "/dev/ttyM%d", min); break; /* conflict */
case 105: sprintf(buf, "/dev/ttyV%d", min); break;
case 112: sprintf(buf, "/dev/ttyM%d", min); break; /* conflict */
#ifdef __CYGWIN__
case 136: sprintf(buf, "/dev/pty%d", min); break;
#else
/* 136 ... 143 are /dev/pts/0, /dev/pts/1, /dev/pts/2 ... */
case 136 ... 143: sprintf(buf, "/dev/pts/%d", min+(maj-136)*256); break;
#endif
case 148: sprintf(buf, "/dev/ttyT%d", min); break;
case 154: sprintf(buf, "/dev/ttySR%d", min); break;
case 156: sprintf(buf, "/dev/ttySR%d", min+256); break;
......@@ -282,6 +296,30 @@ static int link_name(char *restrict const buf, unsigned maj, unsigned min, int p
return 1;
}
#ifdef __CYGWIN__
/* 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) {
char path[32];
FILE *fp;
char *lf;
sprintf (path, "/proc/%d/ctty", pid); /* often permission denied */
fp = fopen (path, "r");
if (!fp)
return 0;
if (!fgets (buf,TTY_NAME_SIZE,fp))
{
fclose (fp);
return 0;
}
fclose (fp);
lf = strchr (buf, '\n');
if (lf)
*lf = (lf == buf ? '?' : '\0');
return 1;
}
#endif
/* number --> name */
unsigned dev_to_tty(char *restrict ret, unsigned chop, dev_t dev_t_dev, int pid, unsigned int flags) {
static char buf[TTY_NAME_SIZE];
......@@ -290,6 +328,9 @@ unsigned dev_to_tty(char *restrict ret, unsigned chop, dev_t dev_t_dev, int pid,
unsigned i = 0;
int c;
if(dev == 0u) goto no_tty;
#ifdef __CYGWIN__
if( ctty_name(tmp, pid )) goto abbrev;
#endif
if(driver_name(tmp, MAJOR_OF(dev), MINOR_OF(dev) )) goto abbrev;
if( link_name(tmp, MAJOR_OF(dev), MINOR_OF(dev), pid, "fd/2" )) goto abbrev;
if( guess_name(tmp, MAJOR_OF(dev), MINOR_OF(dev) )) goto abbrev;
......
......@@ -81,7 +81,7 @@
// Like HIDDEN, but for an alias that gets created.
// In gcc-3.2 there is an alias+hidden conflict.
// Many will have patched this bug, but oh well.
#if ( __GNUC__ == 3 && __GNUC_MINOR__ > 2 ) || __GNUC__ > 3
#if (( __GNUC__ == 3 && __GNUC_MINOR__ > 2 ) || __GNUC__ > 3) && !defined(__CYGWIN__)
#define HIDDEN_ALIAS(x) extern __typeof(x) x##_direct __attribute__((alias(#x),visibility("hidden")))
#else
#define HIDDEN_ALIAS(x) extern __typeof(x) x##_direct __attribute__((alias(#x)))
......
......@@ -612,7 +612,7 @@ LEAVE(0x160);
/////////////////////////////////////////////////////////////////////////
static void statm2proc(const char* s, proc_t *restrict P) {
int num;
int num __attribute__ ((unused));
num = sscanf(s, "%ld %ld %ld %ld %ld %ld %ld",
&P->size, &P->resident, &P->share,
&P->trs, &P->lrs, &P->drs, &P->dt);
......
......@@ -28,6 +28,9 @@
#include <unistd.h>
#include <fcntl.h>
#ifdef __CYGWIN__
#include <sys/param.h>
#endif
#include "alloc.h"
#include "version.h"
#include "sysinfo.h" /* include self to verify prototypes */
......@@ -88,7 +91,9 @@ static char buf[8192];
#define SET_IF_DESIRED(x,y) do{ if(x) *(x) = (y); }while(0)
/* return minimum of two values */
#ifndef __CYGWIN__
#define MIN(x,y) ((x) < (y) ? (x) : (y))
#endif
/***********************************************************************/
int uptime(double *restrict uptime_secs, double *restrict idle_secs) {
......@@ -221,6 +226,7 @@ static void old_Hertz_hack(void){
case 247 ... 252 : Hertz = 250; break;
case 253 ... 260 : Hertz = 256; break;
case 393 ... 408 : Hertz = 400; break; /* normal << 2 */
case 410 ... 600 : Hertz = 500; break; /* SMP WinNT */
case 790 ... 808 : Hertz = 800; break; /* normal << 3 */
case 990 ... 1010 : Hertz = 1000; break; /* ARM */
case 1015 ... 1035 : Hertz = 1024; break; /* Alpha, ia64 */
......@@ -295,6 +301,11 @@ static void init_libproc(void){
Hertz = 100;
return;
#endif /* __FreeBSD__ */
#ifdef __CYGWIN__
// On Cygwin we can rely on the HZ value given in sys/param.h
Hertz = (unsigned long long)HZ; /* <sys/param.h> */
return;
#endif
old_Hertz_hack();
}
......
......@@ -735,6 +735,11 @@ int main(int argc, char ** argv)
else if (strcmp(program_invocation_short_name, "snice") == 0 ||
strcmp(program_invocation_short_name, "lt-snice") == 0)
program = PROG_SNICE;
#ifdef __CYGWIN__
else if (strcmp(program_invocation_short_name, "prockill") == 0 ||
strcmp(program_invocation_short_name, "lt-prockill") == 0)
program = PROG_KILL;
#endif
switch (program) {
case PROG_SNICE:
......
......@@ -13,9 +13,12 @@ if LINUX
# temporarily disabled on other than linux systems, see commit
# 3d807ae853b8b4264da156065b34f1447658a8ba
DEJATOOL += \
pmap \
pmap
if !CYGWIN
DEJATOOL += \
slabtop \
sysctl
endif
if BUILD_KILL
DEJATOOL += kill
......@@ -34,7 +37,7 @@ DEJATOOL += \
endif
EXTRA_DIST = \
config/unix.exp \
config/unix.exp \
free.test/free.exp \
kill.test/kill.exp \
lib.test/fileutils.exp \
......@@ -48,8 +51,11 @@ EXTRA_DIST = \
ps.test/ps_personality.exp \
ps.test/ps_sched_batch.exp \
pwdx.test/pwdx.exp \
slabtop.test/slabtop.exp \
sysctl.test/sysctl_read.exp \
uptime.test/uptime.exp \
vmstat.test/vmstat.exp \
w.test/w.exp
if !CYGWIN
EXTRA_DIST += \
slabtop.test/slabtop.exp \
sysctl.test/sysctl_read.exp
endif
......@@ -28,7 +28,9 @@ proc pgrep_version {} { procps_v_version pgrep }
proc pkill_version {} { procps_v_version pkill }
proc pmap_version {} { procps_v_version pmap }
proc pwdx_version {} { procps_v_version pwdx }
if !CYGWIN
proc sysctl_version {} { procps_v_version sysctl }
endif
proc uptime_version {} { procps_v_version uptime }
proc vmstat_version {} { procps_v_version vmstat }
proc w_version {} { procps_v_version w }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment