Skip to contentSkip to conversation

wfix: sigaltstack(2) example: function pointer

PATCH In review Jan Kasprzak 2 participants 2 messages Nov 29, 2023 Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wfix: sigaltstack(2) example: function pointer

In the following example code:

    sa.sa_handler = handler();      /* Address of a signal handler */

we expect to use a function pointer instead of actually calling a function named handler(). So the parentheses in the above are superfluous. (Unless there is a function named "handler" returning a pointer to some _other_ function, of course).

---
 man2/sigaltstack.2 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
man2/sigaltstack.2 +1 -1
index bd5e6ab..d88d490 100644
@@ -345,7 +345,7 @@ if (sigaltstack(&ss, NULL) == \-1) {
 }
 \&
 sa.sa_flags = SA_ONSTACK;
-sa.sa_handler = handler();      /* Address of a signal handler */
+sa.sa_handler = handler;      /* Address of a signal handler */
 sigemptyset(&sa.sa_mask);
 if (sigaction(SIGSEGV, &sa, NULL) == \-1) {
     perror("sigaction");
Signature · 8 lines
1.8.3.1


-- 
| Jan "Yenya" Kasprzak <kas at {fi.muni.cz - work | yenya.net - private}> |
| https://www.fi.muni.cz/~kas/                        GPG: 4096R/A45477D5 |
    We all agree on the necessity of compromise. We just can't agree on
    when it's necessary to compromise.                     --Larry Wall
#1 lore raw

Hi Jan,

Quoted 6 lines · Jan Kasprzak

In the following example code:

    sa.sa_handler = handler();      /* Address of a signal handler */

we expect to use a function pointer instead of actually calling a function named handler(). So the parentheses in the above are superfluous.

s/superfluous/wrong/

Quoted 4 lines

(Unless there is a function named "handler" returning a pointer to some _other_ function, of course).

Thanks,
Alex

Quoted 26 lines
---
 man2/sigaltstack.2 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
man2/sigaltstack.2 +1 -1
index bd5e6ab..d88d490 100644
@@ -345,7 +345,7 @@ if (sigaltstack(&ss, NULL) == \-1) {
 }
 \&
 sa.sa_flags = SA_ONSTACK;
-sa.sa_handler = handler();      /* Address of a signal handler */
+sa.sa_handler = handler;      /* Address of a signal handler */
 sigemptyset(&sa.sa_mask);
 if (sigaction(SIGSEGV, &sa, NULL) == \-1) {
     perror("sigaction");
Signature · 8 lines
1.8.3.1


-- 
| Jan "Yenya" Kasprzak <kas at {fi.muni.cz - work | yenya.net - private}> |
| https://www.fi.muni.cz/~kas/                        GPG: 4096R/A45477D5 |
    We all agree on the necessity of compromise. We just can't agree on
    when it's necessary to compromise.                     --Larry Wall
Signature · 1 line
<https://www.alejandro-colomar.es/>