473,395 Members | 1,584 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

UNIX signals & C++

Hello,

I am looking for material that describes how *precisely* UNIX-based
signals interact with the normal C++ execution flow of control and
guidelines on how to treat signals in an "object-oriented style".

So far I have not been able to locate much on the subject. Can anyone
provide any pointer/information or suggestion?

Thanks, max
--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
Jul 23 '05 #1
4 6889
maxmagna wrote:
I am looking for material that describes how *precisely* UNIX-based
signals interact with the normal C++ execution flow of control and
guidelines on how to treat signals in an "object-oriented style".

So far I have not been able to locate much on the subject. Can anyone
provide any pointer/information or suggestion?


I'd try a UN*X newsgroup, like comp.unix.*** or comp.os.unix.***
Also, don't discount the newsgroup that discusses your compiler.
Jul 23 '05 #2
* maxmagna:

I am looking for material that describes how *precisely* UNIX-based
signals interact with the normal C++ execution flow of control and
guidelines on how to treat signals in an "object-oriented style".

So far I have not been able to locate much on the subject. Can anyone
provide any pointer/information or suggestion?


§1.9/9:
"When the processing of the abstract machine is interrupted by a signal,
the values of objects with type other than volatile sig_atomic_t are
unspecified, and the value of any object not of volatile sig_atomic_t
that is modified by the handler becomes undefined."

§18.7/5:
.... "All signal handlers shall have C linkage. A POF [Plain Old Function]
that could be used as a signal handler in a conforming C program does not
produce undefined behavior when used as a signal handler in a C++ program.
The behavior of any other function used as a signal handler in a C++
program is implementation defined.(footnote 213)"

(footnote 213) "In particular, a signal handler using exception handling is
very likely to have problems"
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 23 '05 #3
Victor Bazarov wrote:
maxmagna wrote:
I am looking for material that describes how *precisely* UNIX-based
signals interact with the normal C++ execution flow of control and
guidelines on how to treat signals in an "object-oriented style".
I'd try a UN*X newsgroup, like comp.unix.*** or comp.os.unix.***
Also, don't discount the newsgroup that discusses your compiler.


Well, signals are part of the C standard library and thus also part
of standard C++. Of course, the guarantees they offer in the standard
version are rather slim: essentially, you can only assign to an object
of type 'sig_atomic_t volatile' (see 7.14.1.1 paragraph 5) or terminate
the program. I would claim that there is not much "object oriented
style" to use in this case. Actually, I claim that there is not much
"object oriented style" to be used in general because object
orientation (in the sense of using dynamic polymorphism) is just one
of many tools and it is grossly overused but this is a completely
different issue.

The only thing I can image which would warrant some encapsulation is
installing and restoring signal handlers using RAII-techniques.
--
<mailto:di***********@yahoo.com> <http://www.dietmar-kuehl.de/>
<http://www.contendix.com> - Software Development & Consulting

Jul 23 '05 #4
Thanks for the explanations and pointers to what the standard specifies.

My question is motivated by the fact that I'm trying to understand
how to write "safe" C++ code in presence of signals.

Of course, one alternative would be to totally ignore signals.
However, not all signals can be ignored. So, I would like to figure out
a clean manner to do clean up and gracefully end the application.
I have found pointers like "Delivering Signals for Fun and Profit"
by Michal Zalewski, that clearly shows how dangerous signals and
clean up operations can be. But I have not found a description of
what a solution to the problem may be.
--
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Holger Joukl | last post by:
Hi, migrating from good old python 1.5.2 to python 2.3, I have a problem running a program that features some threads which execute calls to an extension module. Problem is that all of a sudden,...
13
by: Siemel Naran | last post by:
Hi. I posted this question to comp.lang.c++, but am rephrasing it a bit from what I learned and posting to comp.lang.c++.moderated for more insight. So how do I solve my problem? I want it so...
4
by: Mantorok Redgormor | last post by:
Should I just avoid them? I have heard many bad things about them 1) if you set a signal handler, you can't really ignore the signal and continue with normal program execution, because after that...
6
by: jose luis fernandez diaz | last post by:
Hi, I have a C program running in background in UNIX. From a shell script I want to notify it some events. The easiest way to do it is through signals, but it is not correct because signal are...
11
by: Jackie | last post by:
Hi everyone, I'd like to know when and how signals are used (e.g. SIGFPE, SIGABRT, SIGTERM, SIGSEGV, SIGINT)? Thank you so much.
0
by: Derek Peschel | last post by:
Should I add an RFE to SourceForge too? I'd like a wide audience in case someone has enough experience to comment or is solving the same problem. I'm using the urwid library which uses curses. ...
5
by: Christian Bruckhoff | last post by:
Hi. I got a problem with Signals and Slots of QT. The program i am speaking of u can find here: http://www.uni-koblenz.de/~brchrist/address/ If u look at gui.cpp u find a connect command at...
6
by: Larthusza | last post by:
I've been called out of retirement to make a small database application for my local crinklies group and am a bit rusty. This is not strictly anything to do with Access per se but that is what I am...
6
by: geoffbache | last post by:
Hi all, I have a Python program (on UNIX) whose main job is to listen on a socket, for which I use the SocketServer module. However, I would also like it to be sensitive to signals received,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.