2017-10-06 4 views
-1

SIGUSR1 및 SIGUSR2 (또는 다른 표준 신호)와 별도로 사용자 정의 된 신호를 정의하고 싶습니다. 어떻게해야합니까?Linux에서 사용자 정의 신호 만들기 커널

+0

정말 어렵습니다. 기본적으로 불가능합니다. 이미 32 개의 신호가 있고 32 비트'int '의 개별 비트와 일치해야합니다. 내가 하나 추가 할 때, 나는 기존 것을 빼앗아 야했다. 하지만 내가 추가하기 시작한 곳은'arch/arm/include/asm/signal.h' (왜냐하면 내가 ARM에서 작업했기 때문에'arch/x86/... '일지도 모름)이었다. 그런 다음 커널 내부에서 내 시그널을 사용자 프로세스로 보내는'internal_kill()'을 호출했다. –

+0

사용자 정의 이름으로 신호 중 하나를 다시 정의하려고했지만 사용자 응용 프로그램에서 신호를 호출 할 때 신호를 인식하지 못합니다. 심지어 저는 ARM에서 일하고 있습니다. – RubberDuck

+0

커널 원본 디렉터리 내의 신호 이름을 정의하는 헤더 파일은 일반 사용자 모드 C 파일이 컴파일 될 때 참조하는 헤더 파일과 다를 수 있습니다. 머리글 파일의 두 인스턴스를 각각 수동으로 동기화해야 할 수도 있습니다. –

답변

1

http://man7.org/linux/man-pages/man7/signal.7.htmlreal time signals을 정의 할 수 있다고 명시합니다. 미리 정의 된 의미는 없습니다. 추가 아무것도 거의 없다

The range of supported real-time signals 
    is defined by the macros SIGRTMIN and SIGRTMAX. POSIX.1-2001 
    requires that an implementation support at least _POSIX_RTSIG_MAX (8) 
    real-time signals. 

    The Linux kernel supports a range of 33 different real-time signals, 
    numbered 32 to 64. However, the glibc POSIX threads implementation 
    internally uses two (for NPTL) or three (for LinuxThreads) real-time 
    signals (see pthreads(7)), and adjusts the value of SIGRTMIN suitably 
    (to 34 or 35). Because the range of available real-time signals 
    varies according to the glibc threading implementation (and this 
    variation can occur at run time according to the available kernel and 
    glibc), and indeed the range of real-time signals varies across UNIX 
    systems, programs should never refer to real-time signals using hard- 
    coded numbers, but instead should always refer to real-time signals 
    using the notation SIGRTMIN+n, and include suitable (run-time) checks 
    that SIGRTMIN+n does not exceed SIGRTMAX. 

: SIGRTMIN+n < SIGRTMAXSIGRTMIN+n를 사용합니다. 컴파일 시간을 확인하십시오 (예 : libc의 구현보다 많은 신호가 필요한 경우 문제가 있음).

뭔가가 있습니다 #define SIGRUBBERDUCK (SIGRTMIN+3)

+0

네,이게 내가 한 짓이고 작동했습니다 ... 고마워요! – RubberDuck

관련 문제