From 5c7d3f916da9a9c93419282e943a7d45c53b9c86 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 21 Sep 2021 09:29:44 +0000 Subject: script/lei: handle SIGTSTP and SIGCONT Sometimes it's useful to pause an expensive query or refresh-mail-sync to do something else. While lei-daemon and lei/store can't be paused since they're shared across clients, per-invocation WQ workers can be paused safely using the unblockable SIGSTOP. While we're at it, drop the ETOOMANYREFS hint since it hasn't been a problem since we drastically reduced FD passing early in development. --- script/lei | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'script/lei') diff --git a/script/lei b/script/lei index 591013e3..399296ba 100755 --- a/script/lei +++ b/script/lei @@ -106,11 +106,10 @@ open my $dh, '<', '.' or die "open(.) $!"; my $buf = join("\0", scalar(@ARGV), @ARGV); while (my ($k, $v) = each %ENV) { $buf .= "\0$k=$v" } $buf .= "\0\0"; -my $n = $send_cmd->($sock, [0, 1, 2, fileno($dh)], $buf, MSG_EOR); -if (!$n) { - die "sendmsg: $! (check RLIMIT_NOFILE)\n" if $!{ETOOMANYREFS}; - die "sendmsg: $!\n"; -} +$send_cmd->($sock, [0, 1, 2, fileno($dh)], $buf, MSG_EOR) or die "sendmsg: $!"; +$SIG{TSTP} = sub { $send_cmd->($sock, [], 'STOP', MSG_EOR); kill 'STOP', $$ }; +$SIG{CONT} = sub { $send_cmd->($sock, [], 'CONT', MSG_EOR) }; + my $x_it_code = 0; while (1) { my (@fds) = $recv_cmd->($sock, my $buf, 4096 * 33); -- cgit v1.2.3-24-ge0c7