Rechercher une page de manuel

Chercher une autre page de manuel:

signal

Autres langues

Langue: pl

Autres versions - même langue

Version: 2000-04-28 (fedora - 25/11/07)

Autres sections - même nom

Section: 2 (Appels système)

NAZWA

signal - obsługa sygnałów ANSI C

SKŁADNIA

#include <signal.h>

typedef void (*sighandler_t)(int);

sighandler_t signal(int signum, sighandler_t handler);

OPIS

Funkcja systemowa signal() instaluje nową obsługę sygnału dla sygnału o numerze signum. Obsługa sygnału ustawiana jest na sighandler, który może być funkcją podaną przez użytkownika lub SIG_IGN albo SIG_DFL.

Po przysłaniu sygnału o numerze signum dzieje się, co następuje. Jeśli obsługa odpowiedniego sygnału została ustawiona na SIG_IGN, to sygnał jest ignorowany. Jeśli obsługa została ustawiona na SIG_DFL, to podejmowana jest domyślna akcja skojarzona z sygnałem (patrz signal(7)). Ostatecznie, Jeśli jako obsługa sygnału została ustawiona function sighandler, to najpierw albo obsługa sygnału jest inicjowana na SIG_DFL albo odbywa się zależne od implementacji blokowanie sygnału, a następnie wywoływana jest funkcja sighandler z argumentem signum.

Używanie funkcji obsługi sygnału jest nazywane "przechwytywaniem sygnału". Sygnały SIGKILL i SIGSTOP nie mogą być ani przechwycone, ani zignorowane.

WARTOŚĆ ZWRACANA

Funkcja signal() zwraca poprzednią wartość obsługi sygnału, lub SIG_ERR w przypadku błędu.

PRZENOŚNOŚĆ

Oryginalne uniksowe signal() zainicjalizowałoby obsługę sygnału na SIG_DFL i to samo robi System V (oraz jądro Linuksa i libc4,5). Z drugiej strony, BSD nie inicjalizuje obsługi sygnału, ale blokuje nowopojawiające się egzemplarze tego sygnału podczas wywoływania funkcji obsługi. Biblioteka glibc2 naśladuje zachowanie BSD.

Jeśli w systemie opartym o libc5 zostanie włączone <bsd/signal.h> zamiast <signal.h>, to signal zostanie przedefiniowane jako __bsd_signal i będzie miało semantykę BSD. Nie jest to zalecane.

Jeśli w systemie opartym o glibc2 zdefiniowane zostanie makro testowania cechy, takie jak _XOPEN_SOURCE lub zostanie użyta osobna funkcja sysv_signal, otrzyma się zachowanie klasyczne. Nie jest to zalecane.

Próba zmiany semantyki tej funkcji za pomocą przedefiniowywania i włączania plików nagłówkowych nie jest dobrym pomysłem. Lepiej w ogóle unikać funkcji signal i posługiwać się zamiast niej sigaction(2).

UWAGI

Zgodnie ze standardem POSIX, zachowanie procesu po zignorowaniu sygnału SIGFPE, SIGILL lub SIGSEGV, który nie był wygenerowany przez funkcję kill(2) ani raise(3), jest niezdefiniowane. Dzielenie przez zero liczby całkowitej nie ma określonego wyniku. Na niektórych architekturach generuje to sygnał SIGFPE. (Również dzielenie najmniejszej liczby ujemnej przez -1 może spowodować wygenerowanie SIGFPE.) Ignorowanie tego sygnału może doprowadzić do pętli nieskończonej.

Zgodnie ze standardem POSIX (3.3.1.3) nie jest określone, co sie stanie gdy SIGCHLD zostanie ustawiony na SIG_IGN. W tym miejscu zachowanie BSD i SYSV różni się, powodując nie działanie na Linuksie oprogramowania BSD, które ustawia akcję dla SIGCHLD na SIG_IGN.

Użycie sighandler_t jest rozszerzeniem GNU. Różne wersje libc predefiniują ten typ; libc4 i libc5 definiują SignalHandler, glibc definiuje sig_t, a gdy zdefiniowane jest _GNU_SOURCE, również sighandler_t.

ZGODNE Z

ANSI C

ZOBACZ TAKŻE

kill(1), kill(2), killpg(2), pause(2), raise(3), sigaction(2), signal(7), sigsetops(3), sigvec(2), alarm(2)
For a time I stood
pondering on circle sizes. The
large computer mainframe quietly
processed all of its assembly code. Inside my entire
hope lay for figuring out an elusive expansion. Value : pi.
Decimals expected soon. I nervously entered a format procedure.
The mainframe processed the request. Error. I, again entering it,
carefully retyped. This iteration gave zero error printouts in all - success.
Intently I waited. Soon, roused by thoughts within me, appeared narrative
mnemonics relating digits to verbiage ! The idea appeared to exist but only in
abbreviated fashion - little phrases typically. Pressing on I then resolved, deciding
firmly about a sum of decimals to use - likely around four hundred, presuming the
computer code soon halted ! Pondering these ideas, words appealed to me. But a
problem of zeros did exist. Pondering more, solution subsequently appeared. Zero
suggests a punctuation element. Very novel ! My thoughts were culminated. No periods, I
concluded. All residual marks of punctuation = zeros. First digit expansion answer then came
before me. On examining some problems unhappily arose. That imbecillic bug ! The printout I
processed showed four nine as foremost decimals. Manifestly troubling. Totally every number
looked wrong. Repairing the bug took much effort. A pi mnemonic with letters truly seemed
good. Counting of all the letters probably should suffice. Reaching for a record would be
helpful. Consequently, I continued, expecting a good final answer from computer. First
number slowly displayed on the flat screen -3. Good. Trailing digits apparently were right
also. Now my memory scheme must be probably implementable. The technique was
chosen, elegant in scheme : by self reference a tale mnemonically helpful was
ensured. An able title suddenly existed - "Circle Digits". Taking pen I began.
Words emanated uneasily. I desired more synonyms. Speedily I found my
(alongside me) Thesaurus. Rogets is probably an essential in doing this,
instantly I decided. I wrote and erased more. The Rogets clearly
assisted immensely. My story proceeded (how lovely !) faultlessly.
The end, above all, would soon joyfully overtake. So, this
memory helper story is incontestably complete. Soon I
will locate publisher. There a narrative will I
trust immediately appear producing
fame. The end.
-- Keith, Michael ; Circle digits : a self referential story