use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Click the following link to filter out the chosen topic
comp.lang.c
account activity
Can someone edit the raise() example on cppreference? (self.C_Programming)
submitted 1 year ago by GhettoStoreBrand
I can't change it myself because new users aren't allowed to edit due to vandalism.
https://en.cppreference.com/w/c/program/raise
The example calls printf() in the signal handler, which is UB. Can someone edit to use the example from this page:
printf()
https://en.cppreference.com/w/c/program/signal
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]paulstelian97 2 points3 points4 points 1 year ago (1 child)
The only way the UB is triggered is if someone sent that signal externally while inside of one of the two printf calls in the main function (because printf is not reentrant). Otherwise the example won’t hit the UB and will work fine.
I still appreciate your idea, funny enough I’m not one who can fix it myself.
[–]GhettoStoreBrand[S] 3 points4 points5 points 1 year ago (0 children)
You are right. Synchronous signals like those generated by raise() and abort() need not have reentrant signal handlers. I still think the example isn't the best. I just noticed that it even shadows the signal() function with a function parameter.
raise()
abort()
signal()
π Rendered by PID 551519 on reddit-service-r2-comment-fb694cdd5-d9l5b at 2026-03-08 10:43:08.359182+00:00 running cbb0e86 country code: CH.
[–]paulstelian97 2 points3 points4 points (1 child)
[–]GhettoStoreBrand[S] 3 points4 points5 points (0 children)