Re: [hackers] [quark][PATCH] Add a config switch to enable/disable NPROC limit
On Sun, 17 Jan 2021 17:29:53 +0100 Giulio Picierro wrote: Dear Giulio, > Quoting the book "The Linux Programming Interface" from Micheal > Kerrisk: "the RLIMIT_NPROC limit, which places a limit on the number > of processes that can be created, is measured against not just that > process’s consumption of the corresponding resource, but also against > the sum of resources consumed by all processes with the same real > user ID." > > This leads quark to easily fail on Linux when launched with the same > userid of a logged user. > > For example if the user 'giulio' has an active desktop session, the > following command: > > $ sudo ./quark -p 8080 -u giulio -g giulio -l > > fails with the following error: > > $ ./quark: pthread_create: Resource temporarily unavailable > > No error occour if instead quark is launched with an userid that does > not have a session, such as the 'http' user, usually reserved for web > servers. > > I don't know if this is expected or this could be considered a bug: > in the end for production servers we could expect that the limit > works correctly. > > In any case, the least invasive way that I have found to solve the > issue is to introduce a config switch to disable the limit, retaining > it enabled by default. that is a really nice observation! Thanks for pointing it out and your elaborate explanation. I must honestly admit that I assumed the limit was per process and not per user. I'll think about how to approach this the best way; given your aforementioned fact, I only see two options: 1) Don't touch the rlimits and let it fail, giving a proper error message (might be problematic for open file descriptors that might get exhausted at runtime). One can also check the limits beforehand and error out (e.g. if we cannot guarantee 4 fds per slot). 2) Uncrement the rlimits by first reading them and setting the incremented value. possible problems here are TOCTOU (even though the risk here is not too high) and a possible interference in things that shouldn't be touched by convention. What do the others think? With best regards Laslo
[hackers] [scroll] discribe the current status of scroll || Jan Klemkow
commit d3d81f46445c69af661102ece1979c880724415e Author: Jan Klemkow AuthorDate: Mon Jan 18 21:42:06 2021 +0100 Commit: Jan Klemkow CommitDate: Mon Jan 18 21:49:16 2021 +0100 discribe the current status of scroll diff --git a/README b/README index 0b5d954..9cb59d2 100644 --- a/README +++ b/README @@ -7,6 +7,23 @@ productive use. The initial version of this program is from Roberto E. Vargas Caballero: https://lists.suckless.org/dev/1703/31256.html +What is the state of scroll? + +The project is faced with some hard facts, that our original plan is not doable +as we thought in the fist place: + + 1. [crtl]+[e] is used in emacs mode (default) on the shell to jump to the end +of the line. But, its also used so signal a scroll down mouse event from +terminal emulators to the shell an other programs. + +- A workaround is to use vi mode in the shell. +- Or to give up mouse support (default behavior) + + 2. scroll could not handle backward cursor jumps and editing of old lines +properly. We just handle current line editing and switching between +alternative screens (curses mode). For a proper end user experience we +would need to write complete new terminal emulator like screen or tmux. + What is the performance impact of scroll? indirectOpenBSD
[hackers] [scroll] fix spacing || Jan Klemkow
commit 7c010c6353e9eac94979287f44d3ee080a9d1a76 Author: Jan Klemkow AuthorDate: Mon Jan 18 21:41:10 2021 +0100 Commit: Jan Klemkow CommitDate: Mon Jan 18 21:46:06 2021 +0100 fix spacing diff --git a/config.def.h b/config.def.h index fb3cd14..536db70 100644 --- a/config.def.h +++ b/config.def.h @@ -8,9 +8,9 @@ struct rule rules[] = { /* sequence eventlines */ - {"\033[5;2~", SCROLL_UP, -1}, /* [Shift] + [PageUP] */ - {"\033[6;2~", SCROLL_DOWN, -1}, /* [Shift] + [PageDown] */ + {"\033[5;2~", SCROLL_UP, -1}, /* [Shift] + [PageUP] */ + {"\033[6;2~", SCROLL_DOWN, -1}, /* [Shift] + [PageDown] */ /* mouse binding shadows ^E and ^Y, so it's disabled by default */ - //{"\031",SCROLL_UP,1}, /* mouse wheel up */ - //{"\005",SCROLL_DOWN, 1}, /* mouse wheel Down */ + //{"\031",SCROLL_UP,1}, /* mouse wheel up */ + //{"\005",SCROLL_DOWN, 1}, /* mouse wheel Down */ };
[hackers] [ubase][PATCH] umount: add support for -t
--- umount.8 | 5 + umount.c | 60 +--- 2 files changed, 49 insertions(+), 16 deletions(-) diff --git a/umount.8 b/umount.8 index c172efb..1309b24 100644 --- a/umount.8 +++ b/umount.8 @@ -11,6 +11,7 @@ .Nm .Op Fl fln .Fl a +.Op Fl t Ar fstypes .Sh DESCRIPTION .Nm detaches the @@ -34,6 +35,10 @@ all references to the filesystem as soon as it is not busy anymore. Unmount without writing in .Pa /etc/mtab . This is the default action. +.It Fl t Ar fstypes +Only act on file systems with types matching those in the comma separated list +fstypes. This list can be prefixed with "no" to act on all filesystems types +except those in the list. .El .Sh SEE ALSO .Xr umount 2 , diff --git a/umount.c b/umount.c index c6d6d9a..55823f5 100644 --- a/umount.c +++ b/umount.c @@ -9,24 +9,48 @@ #include "util.h" static int -umountall(int flags) +matchtype(char *type, char *list) { - FILE *fp; - struct mntent *me; - int ret = 0; - char **mntdirs = NULL; - int len = 0; +int invert = 0; + +if (memcmp(list, "no", 2) == 0) { +invert = 1; +list += 2; +} + +if (*list == ',') +list++; + +while (list) { +if (memcmp(type, list, strlen(type)) == 0) +return !invert; + +if ((list = strchr(list, ',')) != NULL) +list++; +} + +return invert; +} + +static int +umounttype(int flags, char *list) +{ +FILE *fp; +struct mntent *me; +int ret = 0; +char **mntdirs = NULL; +int len = 0; - fp = setmntent("/proc/mounts", "r"); - if (!fp) +fp = setmntent("/proc/mounts", "r"); +if (!fp) eprintf("setmntent %s:", "/proc/mounts"); while ((me = getmntent(fp))) { - if (strcmp(me->mnt_type, "proc") == 0) - continue; - mntdirs = erealloc(mntdirs, ++len * sizeof(*mntdirs)); - mntdirs[len - 1] = estrdup(me->mnt_dir); - } - endmntent(fp); +if (matchtype(me->mnt_type, list)) { +mntdirs = erealloc(mntdirs, ++len * sizeof(*mntdirs)); +mntdirs[len - 1] = estrdup(me->mnt_dir); +} +} +endmntent(fp); while (--len >= 0) { if (umount2(mntdirs[len], flags) < 0) { weprintf("umount2 %s:", mntdirs[len]); @@ -42,7 +66,7 @@ static void usage(void) { weprintf("usage: %s [-lfn] target...\n", argv0); - weprintf("usage: %s -a [-lfn]\n", argv0); + weprintf("usage: %s -a [-lfn] [-t fstype]\n", argv0); exit(1); } @@ -53,6 +77,7 @@ main(int argc, char *argv[]) int aflag = 0; int flags = 0; int ret = 0; +char *typelist = NULL; ARGBEGIN { case 'a': @@ -66,6 +91,9 @@ main(int argc, char *argv[]) break; case 'n': break; + case 't': +typelist = EARGF(usage()); + break; default: usage(); } ARGEND; @@ -74,7 +102,7 @@ main(int argc, char *argv[]) usage(); if (aflag == 1) - return umountall(flags); + return umounttype(flags, typelist ? typelist : "no"); for (i = 0; i < argc; i++) { if (umount2(argv[i], flags) < 0) { -- 2.30.0