Coverage Report

Created: 2026-08-08 07:05

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/brpc/src/bthread/interrupt_pthread.cpp
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
// bthread - An M:N threading library to make applications more concurrent.
19
20
// Date: Tue Jul 10 17:40:58 CST 2012
21
22
#include <signal.h>
23
#include "bthread/interrupt_pthread.h"
24
25
namespace bthread {
26
27
// TODO: Make sure SIGURG is not used by user.
28
// This empty handler is simply for triggering EINTR in blocking syscalls.
29
0
void do_nothing_handler(int) {}
30
31
static pthread_once_t register_sigurg_once = PTHREAD_ONCE_INIT;
32
33
0
static void register_sigurg() {
34
0
    signal(SIGURG, do_nothing_handler);
35
0
}
36
37
0
int interrupt_pthread(pthread_t th) {
38
0
    pthread_once(&register_sigurg_once, register_sigurg);
39
    return pthread_kill(th, SIGURG);
40
0
}
41
42
}  // namespace bthread