[parted-devel] porting to FreeBSD

Siavosh Benabbas sbenabas at gmail.com
Thu Mar 1 22:06:59 CET 2007


Hi,
> One encounters the same problem with Hurd kernel. Although 'sigaction' is
> available in 'signal.h', the absence of SA_SIGINFO does not allow the use of
> a three parameter signal handler with 'sigaction'. One is stuck with the
> single parameter 'signal'-style signal handler. So what I did was write a
> separate signal handler for the two cases, having the same name but with
> different parameter lists. This is not difficult, since all that the three
> parameter signal handler was doing, over and above the single parameter one,
> was to provide some detail about the signal that was being handled. The loss
> of this verbosity, when one can not use a three parameter list signal handler
> with 'sigaction' is acceptable in my opinon.
>
> I had sent a patch to make Parted compile on GNU (Hurd based) systems, which
> does just this. I used a #ifdef SA_SIGINFO...#else...#endif structure to
> selectively handle the two cases. I am still waiting for everybody's opinion
> regarding this, but atleast roughly this is what we can do in my opinion.

Personally I don't think that is very good as it is copy-pasting and
can introduce errors, not that I have much to do with parted
development, just my thoughts.

The problem with FreeBSD is a bit different, freebsd has the sigaction
but it lacks many  MACROs one would check the value of struct
siginfo_t.si_code against! (Sorry if
I wasn't clear last time) This means that you would have a compile
error if you do a #ifdef SA_SIGINFO .
We could place a #ifdef block around any MACRO that sa_flag is checked
against like this:

  switch(x.si_code) {
#ifdef SEGV_MAPERR
     case SEGV_MAPERR:
     //.....
#endif
    //...
    default:
    //....
  }

I don't think this is a good approach because when the "default:" code
is executed you can't be sure which values x.si_code is checked
against. Any way this is a FreeBSD brokenness and I think the best way
to go for FreeBSD is to ignore its sigaction capabilities for now.

Regards,
Siavosh Benabbas



More information about the parted-devel mailing list