signal(7) Miscellaneous Information Manual signal(7) NAZWA signal - przeglad sygnalow OPIS Linux wspiera zarowno rzeczywiste sygnaly POSIX-owe (zwane dalej "sygnalami standardowymi"), jak i sygnaly POSIX-owe czasu rzeczywistego. Zachowania sygnalu Kazdy sygnal ma przypisane biezace zachowanie, ktore okresla reakcje procesu na dostarczony sygnal. The entries in the "Action" column of the table below specify the default disposition for each signal, as follows: Term Domyslna akcja jest przerwanie procesu. Ign Domyslna akcja jest zignorowanie sygnalu. Core Domyslna akcja jest przerwanie procesu i zapisanie obrazu pamieci (patrz core(5)). Stop Domyslna akcja jest zatrzymanie procesu. Cont Domyslna akcja jest kontynuowanie procesu, jezeli jest obecnie zatrzymany. Proces moze zmienic zachowanie sie sygnalu, uzywajac sigaction(2) lub signal(2) (to drugie jest mniej przenosne, jesli chodzi o ustawianie akcji obslugi sygnalu; szczegoly opisano w signal(2)). Uzywajac tych wywolan systemowych, proces moze wybrac jedna z ponizszych reakcji na dostarczenie sygnalu: wykonac domyslna akcje, zignorowac sygnal, przejac sygnal wykonujac akcje obslugi sygnalu, czyli podana przez programiste funkcje, wywolywana automatycznie po dostarczeniu sygnalu. By default, a signal handler is invoked on the normal process stack. It is possible to arrange that the signal handler uses an alternate stack; see sigaltstack(2) for a discussion of how to do this and when it might be useful. Zachowanie sygnalu jest atrybutem poszczegolnych procesow: w aplikacji wielowatkowej zachowanie danego sygnalu jest takie samo dla wszystkich watkow. Dziecko utworzone przez fork(2) dziedziczy kopie ustawien sygnalow od swojego rodzica. Podczas wywolania execve(2) przywracane sa wartosci domyslne ustawien, z wyjatkiem ustawienia ignorowania sygnalu, ktore nie jest zmieniane. Wysylanie sygnalu Nastepujace wywolania systemowe lub funkcje biblioteczne umozliwiaja wysylanie sygnalow: raise(3) Wysyla sygnal do watku, ktory wywolal te funckje. kill(2) Wysyla sygnal do podanego procesu lub do wszystich czlonkow podanej grupy procesow, lub do wszystkich procesow w systemie. pidfd_send_signal(2) Sends a signal to a process identified by a PID file descriptor. killpg(3) Wysyla sygnal do wszystkich czlonkow podanej grupy procesow. pthread_kill(3) Wysyla sygnal do podanego watku POSIX w tym samym procesie, co proces wywolujacy. tgkill(2) Wysyla sygnal do podanego watku w podanym procesie (Jest to uzywane do zaimplementowania pthread_kill(3)). sigqueue(3) Wysyla sygnal czasu rzeczywistego wraz z powiazanymi danymi do podanego procesu. Oczekiwanie na przechwycenie sygnalu The following system calls suspend execution of the calling thread until a signal is caught (or an unhandled signal terminates the process): pause(2) Zawiesza wykonywanie do momentu zlapania sygnalu. sigsuspend(2) Tymczasowo zmienia maske sygnalu (patrz nizej) i zawiesza wykonywanie do momentu przechwycenia jednego z niemaskowanych sygnalow. Synchroniczne akceptowanie sygnalu Zamiast asynchronicznego przechwytywania sygnalu przez procedure jego obslugi, mozliwe jest synchroniczne akceptowanie sygnalow, czyli blokowanie wykonywania do czasu dostarczenia sygnalu, w ktorym to momencie jadro zwraca informacje o sygnale do funkcji wywolujacej. W ogolnosci mozna to zrobic na dwa sposoby: o sigwaitinfo(2), sigtimedwait(2) oraz sigwait(3) zawieszaja wykonanie az do chwili dostarczenia jednego z sygnalow nalezacego do podanego zbioru sygnalow. Kazde z tych wywolan systemowych zwraca informacje o dostarczonym sygnale. o signalfd(2) zwraca deskryptor pliku, ktorego mozna uzyc do odczytania informacji o sygnalach dostarczanych do procesu wywolujacego. Kazda operacja odczytu za pomoca read(2) z tego deskryptora pliku jest blokowana do czasu dostarczenia do programu wywolujacego jednego z sygnalow przekazanych w zbiorze signalfd(2). Bufor zwracany przez read(2) zawiera strukture opisujaca sygnal. Maska sygnalu i sygnaly oczekujace Sygnal moze byc zablokowany, co oznacza, ze nie zostanie dostarczony, dopoki sie go nie odblokuje. Sygnal jest nazywany oczekujacym, jezeli zostal juz wygenerowany, ale nie zostal jeszcze dostarczony. Kazdy watek procesu ma swoja niezalezna maske sygnalow, okreslajaca zbior sygnalow obecnie blokowanych przez watek. Watek moze zmieniac maske sygnalow, uzywajac pthread_sigmask(3). Tradycyjna, jednowatkowa aplikacja moze do tego celu uzyc sigprocmask(2). Dziecko utworzone przez fork(2) dziedziczy kopie maski sygnalow od swojego rodzica. Maska jest zachowywana podczas wywolan execve(2). A signal may be process-directed or thread-directed. A process-directed signal is one that is targeted at (and thus pending for) the process as a whole. A signal may be process-directed because it was generated by the kernel for reasons other than a hardware exception, or because it was sent using kill(2) or sigqueue(3). A thread-directed signal is one that is targeted at a specific thread. A signal may be thread-directed because it was generated as a consequence of executing a specific machine-language instruction that triggered a hardware exception (e.g., SIGSEGV for an invalid memory access, or SIGFPE for a math error), or because it was targeted at a specific thread using interfaces such as tgkill(2) or pthread_kill(3). A process-directed signal may be delivered to any one of the threads that does not currently have the signal blocked. If more than one of the threads has the signal unblocked, then the kernel chooses an arbitrary thread to which to deliver the signal. Watek moze pobrac zbior obecnie oczekujacych sygnalow, uzywajac sigpending(2). Zbior ten bedzie zawieral sygnaly oczekujace skierowane zarowno do calego procesu, jak i do wywolujacego watku. Zbior sygnalow oczekujacych dziecka utworzonego przez fork(2) jest na samym poczatku pusty. Zbior ten jest zachowywany podczas execve(2). Execution of signal handlers Whenever there is a transition from kernel-mode to user-mode execution (e.g., on return from a system call or scheduling of a thread onto the CPU), the kernel checks whether there is a pending unblocked signal for which the process has established a signal handler. If there is such a pending signal, the following steps occur: (1) The kernel performs the necessary preparatory steps for execution of the signal handler: (1.1) The signal is removed from the set of pending signals. (1.2) If the signal handler was installed by a call to sigaction(2) that specified the SA_ONSTACK flag and the thread has defined an alternate signal stack (using sigaltstack(2)), then that stack is installed. (1.3) Various pieces of signal-related context are saved into a special frame that is created on the stack. The saved information includes: o the program counter register (i.e., the address of the next instruction in the main program that should be executed when the signal handler returns); o architecture-specific register state required for resuming the interrupted program; o the thread's current signal mask; o the thread's alternate signal stack settings. (If the signal handler was installed using the sigaction(2) SA_SIGINFO flag, then the above information is accessible via the ucontext_t object that is pointed to by the third argument of the signal handler.) (1.4) Any signals specified in act->sa_mask when registering the handler with sigprocmask(2) are added to the thread's signal mask. The signal being delivered is also added to the signal mask, unless SA_NODEFER was specified when registering the handler. These signals are thus blocked while the handler executes. (2) The kernel constructs a frame for the signal handler on the stack. The kernel sets the program counter for the thread to point to the first instruction of the signal handler function, and configures the return address for that function to point to a piece of user-space code known as the signal trampoline (described in sigreturn(2)). (3) The kernel passes control back to user-space, where execution commences at the start of the signal handler function. (4) When the signal handler returns, control passes to the signal trampoline code. (5) The signal trampoline calls sigreturn(2), a system call that uses the information in the stack frame created in step 1 to restore the thread to its state before the signal handler was called. The thread's signal mask and alternate signal stack settings are restored as part of this procedure. Upon completion of the call to sigreturn(2), the kernel transfers control back to user space, and the thread recommences execution at the point where it was interrupted by the signal handler. Note that if the signal handler does not return (e.g., control is transferred out of the handler using siglongjmp(3), or the handler executes a new program with execve(2)), then the final step is not performed. In particular, in such scenarios it is the programmer's responsibility to restore the state of the signal mask (using sigprocmask(2)), if it is desired to unblock the signals that were blocked on entry to the signal handler. (Note that siglongjmp(3) may or may not restore the signal mask, depending on the savesigs value that was specified in the corresponding call to sigsetjmp(3).) From the kernel's point of view, execution of the signal handler code is exactly the same as the execution of any other user-space code. That is to say, the kernel does not record any special state information indicating that the thread is currently executing inside a signal handler. All necessary state information is maintained in user-space registers and the user-space stack. The depth to which nested signal handlers may be invoked is thus limited only by the user-space stack (and sensible software design!). Sygnaly standardowe Linux supports the standard signals listed below. The second column of the table indicates which standard (if any) specified the signal: "P1990" indicates that the signal is described in the original POSIX.1-1990 standard; "P2001" indicates that the signal was added in SUSv2 and POSIX.1-2001. Sygnal Standard Akcja Komentarz ------------------------------------------------------------------------------- SIGABRT P1990 Core Sygnal abort od abort(3) SIGALRM P1990 Term Sygnal timera od alarm(2) SIGBUS P2001 Core Blad szyny (niepr. dostep do pamieci) SIGCHLD P1990 Ign Potomek zatrzymal sie lub zakonczyl prace SIGCLD - Ign Synonim SIGCHLD SIGCONT P1990 Cont Kontynuuj, jesli sie zatrzymal SIGEMT - Term Emulator trap SIGFPE P1990 Core Wyjatek zmiennoprzecinkowy SIGHUP P1990 Term Zawieszenie wykryte na terminalu kontrol. lub smierc procesu kontrolujacego SIGILL P1990 Core Nielegalna instrukcja SIGINFO - Synonim SIGPWR SIGINT P1990 Term Przerwanie nakazane z klawiatury SIGIO - Term I/O teraz mozliwe (BSD 4.2) SIGIOT - Core pulapka IOT. Synonim SIGABRT SIGKILL P1990 Term Sygnal Kill SIGLOST - Term Utracono blokade pliku (nieuzywane) SIGPIPE P1990 Term Uszkodzony potok: zapis do potoku bez readers; see pipe(7) SIGPOLL P2001 Term Zdarzenie odpytywalne (Sys V); synonim dla SIGIO SIGPROF P2001 Term Przeterminowanie zegara profilowego SIGPWR - Term Blad zasilania (System V) SIGQUIT P1990 Core Wyjscie nakazane z klawiatury SIGSEGV P1990 Core Nieprawidlowa referencja pamieciowa SIGSTKFLT - Term Blad stosu koprocesora (nieuzywany) SIGSTOP P1990 Stop Zatrzymaj proces SIGTSTP P1990 Stop Zatrzymanie napisane z terminala SIGSYS P2001 Core Bad system call (SVr4); see also seccomp(2) SIGTERM P1990 Term Sygnal zakonczenia pracy SIGTRAP P2001 Core Sledzenie/pulapka kontrolna SIGTTIN P1990 Stop Wejscie terminala dla procesu w tle SIGTTOU P1990 Stop Wyjscie terminala dla procesu w tle SIGUNUSED - Core Synonimiczny z SIGSYS SIGURG P2001 Ign Pilny warunek na gniezdzie (BSD 4.2) SIGUSR1 P1990 Term Sygnal 1 uzytkownika SIGUSR2 P1990 Term Sygnal 2 uzytkownika SIGVTALRM P2001 Term Wirtualny zegar alarmu (BSD 4.2) SIGXCPU P2001 Core Przekroczone ogran. czasu CPU (BSD 4.2) see setrlimit(2) SIGXFSZ P2001 Core Przekr. ogran. rozmiaru pliku (BSD 4.2) see setrlimit(2) SIGWINCH - Ign Sygnal zmiany rozm. okna (BSD 4.3, Sun) Sygnalow SIGKILL oraz SIGSTOP nie mozna przechwycic, zablokowac ani zignorowac. Do wersji 2.2 Linuksa (wlacznie) domyslne zachowanie dla sygnalow SIGSYS, SIGXCPU, SIGXFSZ oraz (na architekturach innych niz SPARC i MIPS) SIGBUS polegalo na przerwaniu procesu (bez zrzutu pamieci). (W niektorych innych Uniksach domyslne zachowanie dla SIGXCPU i SIGXFSZ polega na przerwaniu procesu bez zrzutu pamieci). Linux 2.4 jest zgodny ze wymaganiami standardu POSIX.1-2001 dotyczacymi tych sygnalow i przerywa proces ze zrzutem pamieci. SIGEMT nie jest wymieniony w POSIX.1-2001, lecz pomimo to pojawia sie w wiekszosci innych Uniksow. Domyslna akcja dla tego sygnalu jest zazwyczaj przerwanie procesu ze zrzutem pamieci. SIGPWR (niewymieniony w POSIX.1-2001) jest zazwyczaj domyslnie ignorowany w tych Uniksach, w ktorych wystepuje. SIGIO (niewymieniony w POSIX.1-2001) jest domyslnie ignorowany w niektorych innych Uniksach. Queueing and delivery semantics for standard signals If multiple standard signals are pending for a process, the order in which the signals are delivered is unspecified. Standard signals do not queue. If multiple instances of a standard signal are generated while that signal is blocked, then only one instance of the signal is marked as pending (and the signal will be delivered just once when it is unblocked). In the case where a standard signal is already pending, the siginfo_t structure (see sigaction(2)) associated with that signal is not overwritten on arrival of subsequent instances of the same signal. Thus, the process will receive the information associated with the first instance of the signal. Signal numbering for standard signals The numeric value for each signal is given in the table below. As shown in the table, many signals have different numeric values on different architectures. The first numeric value in each table row shows the signal number on x86, ARM, and most other architectures; the second value is for Alpha and SPARC; the third is for MIPS; and the last is for PARISC. A dash (-) denotes that a signal is absent on the corresponding architecture. Sygnal x86/ARM Alpha/ MIPS PARISC Uwagi most others SPARC ----------------------------------------------------------------- SIGHUP 1 1 1 1 SIGINT 2 2 2 2 SIGQUIT 3 3 3 3 SIGILL 4 4 4 4 SIGTRAP 5 5 5 5 SIGABRT 6 6 6 6 SIGIOT 6 6 6 6 SIGBUS 7 10 10 10 SIGEMT - 7 7 - SIGFPE 8 8 8 8 SIGKILL 9 9 9 9 SIGUSR1 10 30 16 16 SIGSEGV 11 11 11 11 SIGUSR2 12 31 17 17 SIGPIPE 13 13 13 13 SIGALRM 14 14 14 14 SIGTERM 15 15 15 15 SIGSTKFLT 16 - - 7 SIGCHLD 17 20 18 18 SIGCLD - - 18 - SIGCONT 18 19 25 26 SIGSTOP 19 17 23 24 SIGTSTP 20 18 24 25 SIGTTIN 21 21 26 27 SIGTTOU 22 22 27 28 SIGURG 23 16 21 29 SIGXCPU 24 24 30 12 SIGXFSZ 25 25 31 30 SIGVTALRM 26 26 28 20 SIGPROF 27 27 29 21 SIGWINCH 28 28 20 23 SIGIO 29 23 22 22 SIGPOLL Same as SIGIO SIGPWR 30 29/- 19 19 SIGINFO - 29/- - - SIGLOST - -/29 - - SIGSYS 31 12 12 31 SIGUNUSED 31 - - 31 Note the following: o Where defined, SIGUNUSED is synonymous with SIGSYS. Since glibc 2.26, SIGUNUSED is no longer defined on any architecture. o Signal 29 is SIGINFO/SIGPWR (synonyms for the same value) on Alpha but SIGLOST on SPARC. Sygnaly czasu rzeczywistego Starting with Linux 2.2, Linux supports real-time signals as originally defined in the POSIX.1b real-time extensions (and now included in POSIX.1-2001). 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. Jadro Linuksa wspiera 33 rozne sygnaly czasu rzeczywistego, o numerach od 32 do 64. Jednakze implementacja watkow POSIX w glibc uzywa dwoch (dla NPTL) lub trzech (dla LinuxThreads) z nich na swoje wewnetrzne potrzeby (patrz pthreads(7)), odpowiednio zmieniajac takze SIGRTMIN (na 34 lub 35). Poniewaz zakres dostepnych sygnalow czasu rzeczywistego zmienia sie zaleznie od implementacji watkow w glibc (roznice moga wystepowac rowniez w czasie dzialania aplikacji, zaleznie od wersji jadra i glibc) i tak naprawde zakres ten rozni sie pomiedzy implementacjami Uniksa, programy nigdy nie powinny sie odwolywac do sygnalow czasu rzeczywistego za pomoca liczb wpisanych na stale, ale powinny zawsze sie odwolywac do sygnalow czasu rzeczywistego uzywajac notacji SIGRTMIN+n, i sprawdzac (podczas dzialania aplikacji), czy SIGRTMIN+n nie przekracza SIGRTMAX. W odroznieniu od sygnalow standardowych, sygnaly czasu rzeczywistego nie maja predefiniowanego znaczenia: mozna wykorzystywac caly zestaw sygnalow czasu rzeczywistego do celow okreslonych w aplikacji. Domysla akcja na nieobsluzony sygnal czasu rzeczywistego jest przerwanie procesu, ktory go otrzymal. Sygnaly czasu rzeczywistego sa rozpoznawane w nastepujacy sposob: o Mozna kolejkowac wiele egzemplarzy sygnalu czasu rzeczywistego. Dla odroznienia, jesli w czasie gdy standardowy sygnal jest blokowany zostanie doreczonych wiele egzemplarzy tego sygnalu, tylko jeden egzemplarzy trafia do kolejki. o Jesli sygnal wyslano korzystajac z sigqueue(3), mozna wyslac wraz z tym sygnalem wartosc towarzyszaca (calkowita lub wskaznik). Jesli proces otrzymujacy ustanawia funkcje obslugi dla tego sygnalu za pomoca znacznika SA_SIGACTION funkcji sigaction(2), to otrzymuje towarzyszaca mu dana za posrednictwem pola si_value struktury siginfo_t przekazanej jako drugi argument funkcji obslugi. Ponadto, pola si_pid oraz si_uid tej struktury moga sluzyc do otrzymania identyfikatora procesu oraz rzeczywistego identyfikatora uzytkownika procesu wysylajacego sygnal. o Sygnaly czasu rzeczywistego sa doreczane w zagwarantowanej kolejnosci. Sygnaly czasu rzeczywistego jednego rodzaju sa doreczane w takiej kolejnosci, w jakiej zostaly wyslane. Jesli do procesu zostana wyslane rozne sygnaly czasu rzeczywistego, beda one doreczone poczawszy od sygnalu o najnizszym numerze. (Tzn. sygnaly o niskich numerach maja najwyzszy priorytet). Sygnaly standardowe zachowuja sie inaczej: jesli kilka standardowych sygnalow oczekuje na proces, to kolejnosc dostarczenia nie jest okreslona. POSIX nie okresla, ktore z sygnalow powinny zostac doreczone jako pierwsze w sytuacji, gdy obsluzenia wymagaja zarowno sygnaly standardowe, jak i sygnaly czasu rzeczywistego. Linux, podobnie do innych implementacji, daje w tym przypadku pierwszenstwo sygnalom standardowym. According to POSIX, an implementation should permit at least _POSIX_SIGQUEUE_MAX (32) real-time signals to be queued to a process. However, Linux does things differently. Up to and including Linux 2.6.7, Linux imposes a system-wide limit on the number of queued real-time signals for all processes. This limit can be viewed and (with privilege) changed via the /proc/sys/kernel/rtsig-max file. A related file, /proc/sys/kernel/rtsig-nr, can be used to find out how many real-time signals are currently queued. In Linux 2.6.8, these /proc interfaces were replaced by the RLIMIT_SIGPENDING resource limit, which specifies a per-user limit for queued signals; see setrlimit(2) for further details. The addition of real-time signals required the widening of the signal set structure (sigset_t) from 32 to 64 bits. Consequently, various system calls were superseded by new system calls that supported the larger signal sets. The old and new system calls are as follows: Linux 2.0 i wczesniejsze Linux 2.2 i pozniejsze sigaction(2) rt_sigaction(2) sigpending(2) rt_sigpending(2) sigprocmask(2) rt_sigprocmask(2) sigreturn(2) rt_sigreturn(2) sigsuspend(2) rt_sigsuspend(2) sigtimedwait(2) rt_sigtimedwait(2) Przerywanie wywolan systemowych i funkcji bibliotecznych przez funkcje obslugi sygnalow Jesli procedura obslugi sygnalu jest wywolana w trakcie wywolania systemowego lub wywolania funkcji bibliotecznej to wtedy albo: o wywolanie jest automatycznie uruchamiane ponownie po zakonczeniu funkcji obslugujacej sygnal, albo o wywolanie zwraca blad EINTR. To, ktore z powyzszych wystapi, zalezy od interfejsu i od tego, czy podczas ustanawiania funkcji obslugi sygnalu uzyto znacznika SA_RESTART (patrz sigaction(2)). Szczegoly sie roznia miedzy roznymi Uniksami, ponizej podano szczegoly dotyczace Linuksa. If a blocked call to one of the following interfaces is interrupted by a signal handler, then the call is automatically restarted after the signal handler returns if the SA_RESTART flag was used; otherwise the call fails with the error EINTR: o Wywolania read(2), readv(2), write(2), writev(2) i ioctl(2) na urzadzeniach "powolnych". Urzadzenie "powolne" to takie, w ktorym operacja wejscia/wyjscia moze sie blokowac przez nieskonczony czas, na przyklad: terminal, potok lub gniazdo. Jesli wywolanie systemowe wejscia/wyjscia na urzadzeniu powolnym spowodowalo juz jakis transfer danych, zanim zostalo przerwane przez sygnal, to zwroci ono pomyslny kod zakonczenie (bedacy zazwyczaj liczba przetransferowanych bajtow). Prosze zauwazyc, ze (lokalny) dysk zgodnie z ta definicja nie jest urzadzeniem powolnym: operacje wejscia/wyjscia na urzadzeniach dyskowych nie sa przerywane sygnalami. o open(2), jesli moze sie zablokowac (np. podczas otwierania FIFO, patrz fifo(7)). o wait(2), wait3(2), wait4(2), waitid(2) i waitpid(2). o Interfejsy gniazd: accept(2), connect(2), recv(2), recvfrom(2), recvmmsg(2), recvmsg(2), send(2), sendto(2) i sendmsg(2), chyba ze ustawiono timeout na gniezdzie (patrz nizej). o Interfejsy blokady plikow: flock(2) i F_SETLKW oraz operacje F_OFD_SETLKW fcntl(2) o Interfejsy kolejek komunikatow POSIX: mq_receive(3), mq_timedreceive(3), mq_send(3) i mq_timedsend(3). o futex(2) FUTEX_WAIT (od Linuksa 2.6.22; wczesniej zawsze zwracal blad EINTR). o getrandom(2). o pthread_mutex_lock(3), pthread_cond_wait(3) i powiazane API. o futex(2) FUTEX_WAIT_BITSET. o Interfejsy semaforow POSIX: sem_wait(3) i sem_timedwait(3) (od Linuksa 2.6.22; wczesniejsze wersje zawsze zwracaly blad EINTR). o read(2) from an inotify(7) file descriptor (since Linux 3.8; beforehand, always failed with EINTR). Nastepujace interfejsy nigdy nie sa wznawiane po przerwaniu przez funkcje obslugi sygnalu, niezaleznie od tego, czy SA_RESTART zostalo uzyte. Jesli zostana przerwane przez funkcje obslugi sygnalu, to zawsze koncza sie niepowodzeniem, zwracajac blad EINTR: o "Wejsciowe" interfejsy gniazd, jesli ustawiono timeout gniazda (SO_RCVTIMEO) za pomoca setsockopt(2): accept(2), recv(2), recvfrom(2), recvmmsg(2) (rowniez z niezerowym argumentem timeout) i recvmsg(2). o "Wyjsciowe" interfejsy gniazd, jesli ustawiono timeout gniazda (SO_RCVTIMEO) za pomoca setsockopt(2): connect(2), send(2), sendto(2) i sendmsg(2). o Interfejsy oczekiwania na sygnaly: pause(2), sigsuspend(2), sigtimedwait(2) i sigwaitinfo(2). o Interfejsy zwielokrotniajace deskryptory plikow: epoll_wait(2), epoll_pwait(2), poll(2), ppoll(2), select(2) i pselect(2). o Interfejsy komunikacji miedzyprocesowej Systemu V: msgrcv(2), msgsnd(2), semop(2) oraz semtimedop(2). o Interfejsy pauzujace proces: clock_nanosleep(2), nanosleep(2) i usleep(3). o io_getevents(2). Funkcja sleep(3) nigdy nie zostanie zrestartowana po przerwaniu przez sygnal i zawsze konczy sie pomyslnie, zwracajac liczbe pozostalych sekund, podczas ktorych proces powinien byl pauzowac. In certain circumstances, the seccomp(2) user-space notification feature can lead to restarting of system calls that would otherwise never be restarted by SA_RESTART; for details, see seccomp_unotify(2). Przerywanie wywolan systemowych i funkcji bibliotecznych przez sygnaly zatrzymujace proces Pod Linuksem, nawet jesli procedury obslugi sygnalu nie zostana ustawione, pewne interfejsy blokujace moga sie zakonczyc niepowodzeniem i zwrocic blad EINTR po tym, jak proces zostanie zatrzymany za pomoca jednego z sygnalow zatrzymujacych (takich jak SIGSTOP), a nastepnie wznowiony za pomoca SIGCONT. POSIX.1 nie wspiera tego zachowania, nie wystepuje ono takze na innych systemach. Nastepujace interfejsy Linuksa zachowuja sie w ten sposob: o "Wejsciowe" interfejsy gniazd, jesli ustawiono timeout gniazda (SO_RCVTIMEO) za pomoca setsockopt(2): accept(2), recv(2), recvfrom(2), recvmmsg(2) (rowniez z niezerowym argumentem timeout) i recvmsg(2). o "Wyjsciowe" interfejsy gniazd, jesli ustawiono timeout gniazda (SO_RCVTIMEO) za pomoca setsockopt(2): connect(2), send(2), sendto(2) i sendmsg(2), jesli ustawiono timeout wysylania danych(SO_SNDTIMEO). o epoll_wait(2), epoll_pwait(2). o semop(2), semtimedop(2). o sigtimedwait(2), sigwaitinfo(2). o Linux 3.7 and earlier: read(2) from an inotify(7) file descriptor o Linux 2.6.21 i wczesniejsze: futex(2) FUTEX_WAIT, sem_timedwait(3), sem_wait(3). o Linux 2.6.8 i wczesniejsze: msgrcv(2), msgsnd(2). o Linux 2.4 i wczesniejsze: nanosleep(2). STANDARDY POSIX.1, z wyjatkami jak podano. UWAGI For a discussion of async-signal-safe functions, see signal-safety(7). The /proc/pid/task/tid/status file contains various fields that show the signals that a thread is blocking (SigBlk), catching (SigCgt), or ignoring (SigIgn). (The set of signals that are caught or ignored will be the same across all threads in a process.) Other fields show the set of pending signals that are directed to the thread (SigPnd) as well as the set of pending signals that are directed to the process as a whole (ShdPnd). The corresponding fields in /proc/pid/status show the information for the main thread. See proc(5) for further details. USTERKI There are six signals that can be delivered as a consequence of a hardware exception: SIGBUS, SIGEMT, SIGFPE, SIGILL, SIGSEGV, and SIGTRAP. Which of these signals is delivered, for any given hardware exception, is not documented and does not always make sense. For example, an invalid memory access that causes delivery of SIGSEGV on one CPU architecture may cause delivery of SIGBUS on another architecture, or vice versa. For another example, using the x86 int instruction with a forbidden argument (any number other than 3 or 128) causes delivery of SIGSEGV, even though SIGILL would make more sense, because of how the CPU reports the forbidden operation to the kernel. ZOBACZ TAKZE kill(1), clone(2), getrlimit(2), kill(2), pidfd_send_signal(2), restart_syscall(2), rt_sigqueueinfo(2), setitimer(2), setrlimit(2), sgetmask(2), sigaction(2), sigaltstack(2), signal(2), signalfd(2), sigpending(2), sigprocmask(2), sigreturn(2), sigsuspend(2), sigwaitinfo(2), abort(3), bsd_signal(3), killpg(3), longjmp(3), pthread_sigqueue(3), raise(3), sigqueue(3), sigset(3), sigsetops(3), sigvec(3), sigwait(3), strsignal(3), swapcontext(3), sysv_signal(3), core(5), proc(5), nptl(7), pthreads(7), sigevent(3type) TLUMACZENIE Autorami polskiego tlumaczenia niniejszej strony podrecznika sa: Przemek Borys , Robert Luberda i Michal Kulach Niniejsze tlumaczenie jest wolna dokumentacja. Blizsze informacje o warunkach licencji mozna uzyskac zapoznajac sie z GNU General Public License w wersji 3 lub nowszej. Nie przyjmuje sie ZADNEJ ODPOWIEDZIALNOSCI. Bledy w tlumaczeniu strony podrecznika prosimy zglaszac na adres listy dyskusyjnej . Linux man-pages 6.06 31 pazdziernika 2023 r. signal(7)