mirror of
https://codeberg.org/dwl/dwl.git
synced 2025-01-30 04:37:28 -08:00
increase RLIMIT_CORE (generate a coredump)
This commit is contained in:
parent
bfa2cbb848
commit
46dcc997e2
1 changed files with 10 additions and 0 deletions
10
dwl.c
10
dwl.c
|
@ -8,6 +8,7 @@
|
|||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/wait.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
@ -363,6 +364,8 @@ static void zoom(const Arg *arg);
|
|||
|
||||
/* variables */
|
||||
static const char broken[] = "broken";
|
||||
static struct rlimit oldrlimit;
|
||||
static struct rlimit newrlimit;
|
||||
static pid_t child_pid = -1;
|
||||
static int locked;
|
||||
static void *exclusive_focus;
|
||||
|
@ -469,6 +472,7 @@ autostartexec(void) {
|
|||
autostart_pids = calloc(autostart_len, sizeof(pid_t));
|
||||
for (p = autostart; *p; i++, p++) {
|
||||
if ((autostart_pids[i] = fork()) == 0) {
|
||||
setrlimit(RLIMIT_CORE, &oldrlimit);
|
||||
setsid();
|
||||
execvp(*p, (char *const *)p);
|
||||
die("dwl: execvp %s failed:", *p);
|
||||
|
@ -2332,6 +2336,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]);
|
||||
|
@ -2756,6 +2761,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);
|
||||
|
@ -3273,6 +3279,10 @@ main(int argc, char *argv[])
|
|||
char *startup_cmd = NULL;
|
||||
int c;
|
||||
|
||||
getrlimit(RLIMIT_CORE, &oldrlimit);
|
||||
newrlimit.rlim_cur = newrlimit.rlim_max = oldrlimit.rlim_max;
|
||||
setrlimit(RLIMIT_CORE, &newrlimit);
|
||||
|
||||
while ((c = getopt(argc, argv, "s:hdv")) != -1) {
|
||||
if (c == 's')
|
||||
startup_cmd = optarg;
|
||||
|
|
Loading…
Reference in a new issue