update coredump patch

38bf347

no one noticed, right?
This commit is contained in:
Leonardo Hernández Hernández 2023-12-29 02:23:18 +00:00
parent 60466305f9
commit 817a61e9b6
No known key found for this signature in database
GPG Key ID: E538897EE11B9624

View File

@ -1,154 +1,65 @@
From c2e65831770a54eebe6eef6e36bfa4716c7e1ada Mon Sep 17 00:00:00 2001 From 38bf34759e5eb3aed9fd14429eee8a1e509c014e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?= From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?=
<leohdz172@proton.me> <leohdz172@protonmail.com>
Date: Sat, 8 Jul 2023 17:11:36 -0600 Date: Wed, 5 Oct 2022 23:07:13 -0500
Subject: [PATCH] port autostart patch from dwm Subject: [PATCH] increase RLIMIT_CORE (generate a coredump)
MIME-Version: 1.0 MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8 Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit
https://dwm.suckless.org/patches/cool_autostart/
Signed-off-by: Leonardo Hernández Hernández <leohdz172@proton.me> Signed-off-by: Leonardo Hernández Hernández <leohdz172@proton.me>
--- ---
config.def.h | 7 +++++++ dwl.c | 9 +++++++++
dwl.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 9 insertions(+)
2 files changed, 61 insertions(+), 5 deletions(-)
diff --git a/config.def.h b/config.def.h
index a8ed61d..3585711 100644
--- a/config.def.h
+++ b/config.def.h
@@ -20,6 +20,13 @@ static const float fullscreen_bg[] = {0.1, 0.1, 0.1, 1.0}; /* You can al
/* logging */
static int log_level = WLR_ERROR;
+/* Autostart */
+static const char *const autostart[] = {
+ "wbg", "/path/to/your/image", NULL,
+ NULL /* terminate */
+};
+
+
static const Rule rules[] = {
/* app_id title tags mask isfloating monitor */
/* examples:
diff --git a/dwl.c b/dwl.c diff --git a/dwl.c b/dwl.c
index edf0cf1..4b7adc8 100644 index 10d5a5b..62cdb5a 100644
--- a/dwl.c --- a/dwl.c
+++ b/dwl.c +++ b/dwl.c
@@ -236,6 +236,7 @@ static void arrange(Monitor *m); @@ -7,6 +7,7 @@
static void arrangelayer(Monitor *m, struct wl_list *list, #include <signal.h>
struct wlr_box *usable_area, int exclusive); #include <stdio.h>
static void arrangelayers(Monitor *m); #include <stdlib.h>
+static void autostartexec(void); +#include <sys/resource.h>
static void axisnotify(struct wl_listener *listener, void *data); #include <sys/wait.h>
static void buttonpress(struct wl_listener *listener, void *data); #include <time.h>
static void chvt(const Arg *arg); #include <unistd.h>
@@ -403,6 +404,9 @@ static xcb_atom_t netatom[NetLast]; @@ -334,6 +335,8 @@ static void zoom(const Arg *arg);
/* attempt to encapsulate suck into one file */
#include "client.h"
+static pid_t *autostart_pids; /* variables */
+static size_t autostart_len; static const char broken[] = "broken";
+ +static struct rlimit oldrlimit;
/* function implementations */ +static struct rlimit newrlimit;
void static pid_t child_pid = -1;
applybounds(Client *c, struct wlr_box *bbox) static int locked;
@@ -533,6 +537,27 @@ arrangelayers(Monitor *m) static void *exclusive_focus;
} @@ -1972,6 +1975,7 @@ run(char *startup_cmd)
} if ((child_pid = fork()) < 0)
die("startup: fork:");
if (child_pid == 0) {
+ setrlimit(RLIMIT_CORE, &oldrlimit);
dup2(piperw[0], STDIN_FILENO);
close(piperw[0]);
close(piperw[1]);
@@ -2410,6 +2414,7 @@ void
spawn(const Arg *arg)
{
if (fork() == 0) {
+ setrlimit(RLIMIT_CORE, &oldrlimit);
dup2(STDERR_FILENO, STDOUT_FILENO);
setsid();
execvp(((char **)arg->v)[0], (char **)arg->v);
@@ -2928,6 +2933,10 @@ main(int argc, char *argv[])
char *startup_cmd = NULL;
int c;
+void + getrlimit(RLIMIT_CORE, &oldrlimit);
+autostartexec(void) { + newrlimit.rlim_cur = newrlimit.rlim_max = oldrlimit.rlim_max;
+ const char *const *p; + setrlimit(RLIMIT_CORE, &newrlimit);
+ size_t i = 0;
+ +
+ /* count entries */ while ((c = getopt(argc, argv, "s:hdv")) != -1) {
+ for (p = autostart; *p; autostart_len++, p++) if (c == 's')
+ while (*++p); startup_cmd = optarg;
+
+ autostart_pids = calloc(autostart_len, sizeof(pid_t));
+ for (p = autostart; *p; i++, p++) {
+ if ((autostart_pids[i] = fork()) == 0) {
+ setsid();
+ execvp(*p, (char *const *)p);
+ die("dwl: execvp %s:", *p);
+ }
+ /* skip arguments */
+ while (*++p);
+ }
+}
+
void
axisnotify(struct wl_listener *listener, void *data)
{
@@ -630,11 +655,21 @@ checkidleinhibitor(struct wlr_surface *exclude)
void
cleanup(void)
{
+ size_t i;
#ifdef XWAYLAND
wlr_xwayland_destroy(xwayland);
xwayland = NULL;
#endif
wl_display_destroy_clients(dpy);
+
+ /* kill child processes */
+ for (i = 0; i < autostart_len; i++) {
+ if (0 < autostart_pids[i]) {
+ kill(autostart_pids[i], SIGTERM);
+ waitpid(autostart_pids[i], NULL, 0);
+ }
+ }
+
if (child_pid > 0) {
kill(child_pid, SIGTERM);
waitpid(child_pid, NULL, 0);
@@ -1295,18 +1330,31 @@ void
handlesig(int signo)
{
if (signo == SIGCHLD) {
-#ifdef XWAYLAND
siginfo_t in;
/* wlroots expects to reap the XWayland process itself, so we
* use WNOWAIT to keep the child waitable until we know it's not
* XWayland.
*/
while (!waitid(P_ALL, 0, &in, WEXITED|WNOHANG|WNOWAIT) && in.si_pid
- && (!xwayland || in.si_pid != xwayland->server->pid))
- waitpid(in.si_pid, NULL, 0);
-#else
- while (waitpid(-1, NULL, WNOHANG) > 0);
+#ifdef XWAYLAND
+ && (!xwayland || in.si_pid != xwayland->server->pid)
#endif
+ ) {
+ pid_t *p, *lim;
+ waitpid(in.si_pid, NULL, 0);
+ if (in.si_pid == child_pid)
+ child_pid = -1;
+ if (!(p = autostart_pids))
+ continue;
+ lim = &p[autostart_len];
+
+ for (; p < lim; p++) {
+ if (*p == in.si_pid) {
+ *p = -1;
+ break;
+ }
+ }
+ }
} else if (signo == SIGINT || signo == SIGTERM) {
quit(NULL);
}
@@ -1966,6 +2014,7 @@ run(char *startup_cmd)
die("startup: backend_start");
/* Now that the socket exists and the backend is started, run the startup command */
+ autostartexec();
if (startup_cmd) {
int piperw[2];
if (pipe(piperw) < 0)
-- --
2.43.0 2.43.0