Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

We have a equal opportunity Calculus class -- it's fully integrated.


devel / comp.unix.programmer / Re: Assignment between objects of type sigset_t

SubjectAuthor
* Assignment between objects of type sigset_tSpiros Bousbouras
`- Re: Assignment between objects of type sigset_tRainer Weikusat

1
Assignment between objects of type sigset_t

<hl4fYS2ONoKq9MnWB@bongo-ra.co>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16597&group=comp.unix.programmer#16597

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!fx01.ams4.POSTED!not-for-mail
From: spibou@gmail.com (Spiros Bousbouras)
Newsgroups: comp.unix.programmer
Subject: Assignment between objects of type sigset_t
Message-ID: <hl4fYS2ONoKq9MnWB@bongo-ra.co>
X-Organisation: Weyland-Yutani
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Lines: 48
X-Complaints-To: http://netreport.virginmedia.com
NNTP-Posting-Date: Thu, 03 Jun 2021 13:29:07 UTC
Organization: virginmedia.com
Date: Thu, 03 Jun 2021 13:29:07 GMT
X-Received-Bytes: 2545
 by: Spiros Bousbouras - Thu, 3 Jun 2021 13:29 UTC

int main(void) {
struct sigaction sact , sact_old ;

// Definitions for functions handler() and fatal() not shown ; assume
// they have no issues.

if (sigaction(SIGCHLD , 0 , &sact_old) == -1)
fatal("sigaction() call to get the original signal handling failed") ;
sact.sa_handler = handler ;
sact.sa_flags = 0 ;
sact.sa_mask = sact_old.sa_mask ; // *** Is this OK ? ***
if (sigaction(SIGCHLD , &sact , 0) == -1)
fatal("sigaction(SIGCHLD , ...) failed") ;

....................
}

https://pubs.opengroup.org/onlinepubs/9699919799/functions/sigemptyset.html :
RATIONALE

The implementation of the sigemptyset() (or sigfillset()) function
could quite trivially clear (or set) all the bits in the signal set.
Alternatively, it would be reasonable to initialize part of the
structure, such as a version field, to permit binary-compatibility
between releases where the size of the set varies. For such reasons,
either sigemptyset() or sigfillset() must be called prior to any
other use of the signal set, even if such use is read-only (for
example, as an argument to sigpending()).

If we take this literally then what my code does above is not ok. On the other
hand what I do seems reasonable and the only alternative would be something
like

sigemptyset(&sact.sa_mask) ;
Have variable sig loop over all signals {
if sigismember(&sact_old.sa_mask , sig) sigaddset(&sact.sa_mask , sig) ;
}

If the assignment is not ok then it would be nice if POSIX had something like
sigcopyset(sigset_t *set1 , sigset_t *set2)

GNU offers sigorset(...) but I don't want to use extensions.

--
Somebody was trying to tell me that CDs are better than vinyl because
they don't have any surface noise. I said, "Listen, mate, life has
surface noise."
John Peel

Re: Assignment between objects of type sigset_t

<87y2brrm50.fsf@doppelsaurus.mobileactivedefense.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16599&group=comp.unix.programmer#16599

  copy link   Newsgroups: comp.unix.programmer
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: rweikusat@talktalk.net (Rainer Weikusat)
Newsgroups: comp.unix.programmer
Subject: Re: Assignment between objects of type sigset_t
Date: Thu, 03 Jun 2021 16:41:31 +0100
Lines: 55
Message-ID: <87y2brrm50.fsf@doppelsaurus.mobileactivedefense.com>
References: <hl4fYS2ONoKq9MnWB@bongo-ra.co>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net vhUfbzbDHz/360o8yf/p6ARepCVf7Q55lHO4AdnfWuecLl5FY=
Cancel-Lock: sha1:7/RGhv09tR6xki/aG7sIy88/3Fg= sha1:yMw1TEvW5qOa+51uicJ/gHU9nwg=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
 by: Rainer Weikusat - Thu, 3 Jun 2021 15:41 UTC

Spiros Bousbouras <spibou@gmail.com> writes:
> int main(void) {
> struct sigaction sact , sact_old ;
>
> // Definitions for functions handler() and fatal() not shown ; assume
> // they have no issues.
>
> if (sigaction(SIGCHLD , 0 , &sact_old) == -1)
> fatal("sigaction() call to get the original signal handling failed") ;

[...]

> sact.sa_mask = sact_old.sa_mask ; // *** Is this OK ? ***

[...]

> https://pubs.opengroup.org/onlinepubs/9699919799/functions/sigemptyset.html :
> RATIONALE
>
> The implementation of the sigemptyset() (or sigfillset()) function
> could quite trivially clear (or set) all the bits in the signal set.
> Alternatively, it would be reasonable to initialize part of the
> structure, such as a version field, to permit binary-compatibility
> between releases where the size of the set varies. For such reasons,
> either sigemptyset() or sigfillset() must be called prior to any
> other use of the signal set, even if such use is read-only (for
> example, as an argument to sigpending()).
>
> If we take this literally then what my code does above is not ok.

Presumably, somebody who's in fan of "undefined behaviour on signed
integer overflow" could construct an argument carefully avoiding to fall
foul of anything that's explicitly mentioned in the text above in order
to make such a claim. But this can be done in any case and is besides the
point, as it ignores the context.

sigemptyset is a function for initializing a sigset_t. Superficially, it
could seem redundant in certain situations because a sigset_t with
storage class "static" will have its memory initialized to all zero
bytes. The rationale just cautions that a sigset_t initialized in this
way isn't necessarily equivalent to "an empty signal set". An even
simpler reason for this could be that "empty" could as well be
represented as "all bits set" as as "all bits clear".

But that's irrlevant for sigset_t assignments. That's a C operation
whose semantics and/or validity depends on the types of the involved
objects.

https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html

demands that sigset_t is an "Integer or structure type", hence, sigset_t
can be used in assignments.

An implementation could sabotage this, but unless specifically
targetting one known to act in this way, I'd ignore the possibility.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor