diff options
-rw-r--r-- | lib/PublicInbox/XapHelper.pm | 4 | ||||
-rw-r--r-- | lib/PublicInbox/xap_helper.h | 6 |
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/PublicInbox/XapHelper.pm b/lib/PublicInbox/XapHelper.pm index 0e79e5e2..e8eeb2dc 100644 --- a/lib/PublicInbox/XapHelper.pm +++ b/lib/PublicInbox/XapHelper.pm @@ -10,6 +10,7 @@ $GLP->configure(qw(require_order bundling no_ignore_case no_auto_abbrev)); use PublicInbox::Search qw(xap_terms); use PublicInbox::CodeSearch; use PublicInbox::IPC; +use Socket qw(SOL_SOCKET SO_TYPE SOCK_SEQPACKET AF_UNIX); use PublicInbox::DS qw(awaitpid); use POSIX qw(:signal_h); use Fcntl qw(LOCK_UN LOCK_EX); @@ -254,6 +255,9 @@ sub xh_alive { $alive || scalar(keys %WORKERS) } sub start (@) { my (@argv) = @_; + my $c = getsockopt(STDIN, SOL_SOCKET, SO_TYPE) or die "getsockopt: $!"; + unpack('i', $c) == SOCK_SEQPACKET or die 'stdin is not SOCK_SEQPACKET'; + local (%SRCH, %WORKERS); local $alive = 1; PublicInbox::Search::load_xapian(); diff --git a/lib/PublicInbox/xap_helper.h b/lib/PublicInbox/xap_helper.h index a2fea266..2322d062 100644 --- a/lib/PublicInbox/xap_helper.h +++ b/lib/PublicInbox/xap_helper.h @@ -1108,6 +1108,12 @@ static size_t living_workers(void) int main(int argc, char *argv[]) { int c; + socklen_t slen = (socklen_t)sizeof(c); + + if (getsockopt(sock_fd, SOL_SOCKET, SO_TYPE, &c, &slen)) + err(EXIT_FAILURE, "getsockopt"); + if (c != SOCK_SEQPACKET) + errx(EXIT_FAILURE, "stdin is not SOCK_SEQPACKET"); mail_nrp_init(); code_nrp_init(); |