Re: mmap, SIGBUS, and handling it

Alex Riesen (Alexander.Riesen@synopsys.com)
Sat, 11 May 2002 15:27:38 +0200


On Fri, May 10, 2002 at 07:04:36PM +0300, Mihai RUSU wrote:
> On Fri, 10 May 2002, David S. Miller wrote:
>
> > From: Mihai RUSU <dizzy@roedu.net>
> > Date: Fri, 10 May 2002 18:37:21 +0300 (EEST)
> >
> > PS: why signal(SIGBUS,SIG_IGN) doesnt work, but a user handler its called
> > if set with signal(SIGBUS,handle_sigbus) ?
> >
> > How would you like the kernel to "ignore" a page fault that cannot be
> > serviced?
> >
>
> You are right, its not that I want to ignore it. The problem was that I
> want to handle it some way but I dont know how. If I will make a user
> handler for it how can I know if its a SIGBUS from a HW error or a SIGBUS
> from that write()-case. Because I have to continue serving files even
> after received a SIGBUS in that write (otherwise my file server will exit
> with SIGBUS and thats no good :) ).
>
> Take for example any single process ftp/http server, they are hit by this
> problem. Which solution would you recommend ? :)
>

Just take a closer look on sigaction(2). The field sa_sigaction and
flags SA_SIGINFO in sa_flags can help to identify the source of the
SIGBUS.

SIGACTION(2) Linux Programmer's Manual SIGACTION(2)
...
the sender of the POSIX.1b signal. SIGILL, SIGFPE,
SIGSEGV and SIGBUS fill in si_addr with the address of the
fault. SIGPOLL fills in si_band and si_fd.
...
si_code indicates why this signal was sent. It is a
value, not a bitmask. The values which are possible for
any signal are listed in this table:
...
| SIGBUS |
+-----------+--------------------------------+
|BUS_ADRALN | invalid address alignment |
+-----------+--------------------------------+
|BUS_ADRERR | non-existent physical address |
+-----------+--------------------------------+
|BUS_OBJERR | object specific hardware error |

-alex
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/