git: 7418bfa0e658 - main - sysutils/screen: Add session creation time when list active sessions
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 16 Aug 2023 13:52:44 UTC
The branch main has been updated by rodrigo: URL: https://cgit.FreeBSD.org/ports/commit/?id=7418bfa0e65838e7f94bd82d1e02c5aac79b0555 commit 7418bfa0e65838e7f94bd82d1e02c5aac79b0555 Author: Rodrigo Osorio <rodrigo@FreeBSD.org> AuthorDate: 2023-08-15 11:19:35 +0000 Commit: Rodrigo Osorio <rodrigo@FreeBSD.org> CommitDate: 2023-08-16 13:52:05 +0000 sysutils/screen: Add session creation time when list active sessions Reimplement Debian patches to display screen session creation time and sort the list of sessions by date. Output example for 'screen -ls' command --------------------------------------- There is a screen on: 14059.pts-7.1302amd64-head (08/15/23 10:02:52) (Attached) 1 Socket in /tmp/screens/S-root. Reviewed by: cy Differential Revision: https://reviews.freebsd.org/D41469 --- sysutils/screen/Makefile | 2 +- sysutils/screen/files/patch-doc_screen.1 | 11 +++++ sysutils/screen/files/patch-extern.h | 8 +++ sysutils/screen/files/patch-misc.c | 31 ++++++++++++ sysutils/screen/files/patch-socket.c | 84 ++++++++++++++++++++++++++++++++ 5 files changed, 135 insertions(+), 1 deletion(-) diff --git a/sysutils/screen/Makefile b/sysutils/screen/Makefile index 050b2c503fff..a75a39f3146b 100644 --- a/sysutils/screen/Makefile +++ b/sysutils/screen/Makefile @@ -1,6 +1,6 @@ PORTNAME= screen PORTVERSION= 4.9.0 -PORTREVISION= 6 +PORTREVISION= 7 CATEGORIES= sysutils MASTER_SITES= GNU \ ftp://ftp.gnu.org/gnu/screen/ \ diff --git a/sysutils/screen/files/patch-doc_screen.1 b/sysutils/screen/files/patch-doc_screen.1 new file mode 100644 index 000000000000..59077d7be443 --- /dev/null +++ b/sysutils/screen/files/patch-doc_screen.1 @@ -0,0 +1,11 @@ +--- doc/screen.1.orig 2023-08-15 11:01:59 UTC ++++ doc/screen.1 +@@ -241,7 +241,7 @@ + .IR screen , + but prints a list of + .I pid.tty.host +-strings identifying your ++strings and creation timestamps identifying your + .I screen + sessions. + Sessions marked `detached' can be resumed with \*Qscreen \-r\*U. Those marked diff --git a/sysutils/screen/files/patch-extern.h b/sysutils/screen/files/patch-extern.h new file mode 100644 index 000000000000..99e9063cdd0f --- /dev/null +++ b/sysutils/screen/files/patch-extern.h @@ -0,0 +1,8 @@ +--- extern.h.orig 2023-08-15 08:44:47 UTC ++++ extern.h +@@ -512,3 +512,5 @@ + /* layout.c */ + extern void RemoveLayout __P((struct layout *)); + extern int LayoutDumpCanvas __P((struct canvas *, char *)); ++ ++extern time_t SessionCreationTime __P((const char *)); diff --git a/sysutils/screen/files/patch-misc.c b/sysutils/screen/files/patch-misc.c new file mode 100644 index 000000000000..1364b230d55a --- /dev/null +++ b/sysutils/screen/files/patch-misc.c @@ -0,0 +1,31 @@ +--- misc.c.orig 2022-01-28 14:06:02 UTC ++++ misc.c +@@ -28,8 +28,10 @@ + + #include <poll.h> + #include <sys/types.h> ++#include <sys/user.h> + #include <sys/stat.h> /* mkdir() declaration */ + #include <signal.h> ++#include <libutil.h> + + #include "config.h" + #include "screen.h" +@@ -796,3 +798,17 @@ + } + + #endif ++ ++time_t ++SessionCreationTime(fifo) ++const char *fifo; ++{ ++ int pid = atoi(fifo); ++ if (pid <= 0) return 0; ++ ++ struct kinfo_proc * kip = kinfo_getproc(pid); ++ if (kip == 0) return 0; ++ time_t start = kip->ki_start.tv_sec; ++ free (kip); ++ return start; ++} diff --git a/sysutils/screen/files/patch-socket.c b/sysutils/screen/files/patch-socket.c new file mode 100644 index 000000000000..cfa52856c2e7 --- /dev/null +++ b/sysutils/screen/files/patch-socket.c @@ -0,0 +1,84 @@ +--- socket.c.orig 2022-01-28 14:06:02 UTC ++++ socket.c +@@ -141,12 +141,14 @@ + char *firstn = NULL; + int nfound = 0, ngood = 0, ndead = 0, nwipe = 0, npriv = 0; + int nperfect = 0; ++ char timestr[64]; + struct sent + { + struct sent *next; + int mode; + char *name; +- } *slist, **slisttail, *sent, *nsent; ++ time_t time_created; ++ } *slist, **slisttail, *sent, *nsent, *schosen; + + if (match) + { +@@ -258,8 +260,13 @@ + sent->next = 0; + sent->name = SaveStr(name); + sent->mode = mode; ++ sent->time_created = SessionCreationTime(name); ++ for (slisttail = &slist; *slisttail; slisttail = &((*slisttail)->next)) ++ { ++ if ((*slisttail)->time_created < sent->time_created) break; ++ } ++ sent->next = *slisttail; + *slisttail = sent; +- slisttail = &sent->next; + nfound++; + sockfd = MakeClientSocket(0, *is_sock); + #ifdef USE_SETEUID +@@ -359,34 +366,42 @@ + } + for (sent = slist; sent; sent = sent->next) + { ++ if (sent->time_created == 0) ++ { ++ sprintf(timestr, "??" "?"); ++ } ++ else ++ { ++ strftime(timestr, 64, "%x %X", localtime(&sent->time_created)); ++ } + switch (sent->mode) + { + case 0700: +- printf("\t%s\t(Attached)\n", sent->name); ++ printf("\t%s\t(%s)\t(Attached)\n", sent->name, timestr); + break; + case 0600: +- printf("\t%s\t(Detached)\n", sent->name); ++ printf("\t%s\t(%s)\t(Detached)\n", sent->name, timestr); + break; + #ifdef MULTIUSER + case 0701: +- printf("\t%s\t(Multi, attached)\n", sent->name); ++ printf("\t%s\t(%s)\t(Multi, attached)\n", sent->name, timestr); + break; + case 0601: +- printf("\t%s\t(Multi, detached)\n", sent->name); ++ printf("\t%s\t(%s)\t(Multi, detached)\n", sent->name, timestr); + break; + #endif + case -1: + /* No trigraphs here! */ +- printf("\t%s\t(Dead ?%c?)\n", sent->name, '?'); ++ printf("\t%s\t(%s)\t(Dead ?%c?)\n", sent->name, timestr, '?'); + break; + case -2: +- printf("\t%s\t(Removed)\n", sent->name); ++ printf("\t%s\t(%s)\t(Removed)\n", sent->name, timestr); + break; + case -3: +- printf("\t%s\t(Remote or dead)\n", sent->name); ++ printf("\t%s\t(%s)\t(Remote or dead)\n", sent->name, timestr); + break; + case -4: +- printf("\t%s\t(Private)\n", sent->name); ++ printf("\t%s\t(%s)\t(Private)\n", sent->name, timestr); + break; + } + }