🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.os.linux.programowanie
Article #72583

Re: Przejmowanie sygnały dzielenia przez zero

#72583
From: Aleksander Nabagło
Date: Thu, 13 Dec 2012 07:37
45 lines
2010 bytes
Borneq pisze:
> #include <stdio.h>
> #include <stdlib.h>
> #include <signal.h>
> 
> int handle (int signo)
> {
> printf ("z handle, signo=%d\n",signo);
> }
The routine handler must be very careful,
since	 processing  elsewhere
was interrupted at some arbitrary point.
POSIX has the concept of "safe function".
If a signal interrupts  an  unsafe  function,
and  handler calls  an  unsafe  function,
then the behavior is undefined. Safe func-
tions are listed explicitly in the various standards.

> int inv(int n)//float,int 1/0 SIGFPE = 8
> {
>    return 1/n;
> }
> 
> int main()
> {
>    void (*SIGFPE_saved) ();
> 
>    SIGFPE_saved = signal (SIGFPE, handle);
>    inv(abs(0));
>    printf ("po inv\n");
>    signal (SIGFPE, SIGFPE_saved);
>    return 0;
> }
> 
> Co zrobić aby w kólko nie wywoływał handle() ?
Jakiego typu musi byc 'handle'?

Ponadto, funkcja 'printf' nie znajduje sie
na liscie POSIX bezpiecznych funkcji (czyli dzialanie
programu jest nieokreslone, jesli zostanie uzyta
w handlerze).

-- 
A
.
Technical Details
Message-ID: <kabvk9$eua$1@srv.cyf-kr.edu.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!pwr.wroc.pl!news.wcss.wroc.pl!news.man.lodz.pl!news.nask.pl!news.nask.org.pl!news.cyf-kr.edu.pl!not-for-mail
References: <ka2v0b$92u$1@node2.news.atman.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!pwr.wroc.pl!news.wcss.wroc.pl!news.man.lodz.pl!news.nask.pl!news.nask.org.pl!news.cyf-kr.edu.pl!not-for-mail
From: Aleksander Nabagło <n@ap.krakow.pl>
Newsgroups: pl.comp.os.linux.programowanie
Subject: Re: Przejmowanie sygnały dzielenia przez zero
Date: Thu, 13 Dec 2012 08:37:35 +0100
Organization: Academic Computer Center CYFRONET AGH
Lines: 45
Message-ID: <kabvk9$eua$1@srv.cyf-kr.edu.pl>
References: <ka2v0b$92u$1@node2.news.atman.pl>
NNTP-Posting-Host: adm-gate.ap.krakow.pl
Mime-Version: 1.0
X-Trace: srv.cyf-kr.edu.pl 1355383241 15306 149.156.24.29 (13 Dec 2012 07:20:41 GMT)
X-Complaints-To: news@cyf-kr.edu.pl
NNTP-Posting-Date: Thu, 13 Dec 2012 07:20:41 +0000 (UTC)
User-Agent: Thunderbird 2.0.0.23 (X11/20100301)
In-Reply-To: <ka2v0b$92u$1@node2.news.atman.pl>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit