473,698 Members | 2,588 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 6909
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.(footno te 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.co m> <http://www.dietmar-kuehl.de/>
<http://www.contendix.c om> - 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
2054
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, I cannot stop the program with a keyboard interrupt any more; the installed signal handler does not seem to receive the signal at all. This happens both if I rebuild this extension using python 2.3 headers/library and if I simply use the old...
13
4869
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 that when the user presses Ctrl-C or eds the task from task manager (or the kill command in UNIX) then the system should shutdown gracefully. This means it should call the destructors of all objects, which means freeing dynamic memory, closing...
4
1692
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 undefined behavior is invoked. 2) if you have a signal handler set for say SIG_INT and you continue to reset the handler after you received the signal, to continue normal program execution, and the signal is received twice or something you end...
6
2896
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 not a event drivent framework. Can anyone give me other straightforward solution ? Thanks, Jose Luis.
11
2967
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
1618
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. On my system (Mac OS 10.3.7) I specifically have ncurses. The programs I'm running turn off echoing and set raw mode but don't disable interrupts. For development purposes I like having interrupts, but my preferred keystrokes (WordStar) conflict...
5
2228
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 line 27. I would read this command like this: "If pushButtonAddPerson got clicked call the function addPerson() of this GUI-Object" So this connect should call the function starting on line 50. But if i start
6
2671
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 using and I'm sure it is no great challenge to the excellent people who meet here. I have made my application in Delphi which uses MS Access tables and which are very small, 100 or so records, which runs across a network from a UNIX server...
6
2382
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, which it isn't if it's listening on the socket. ("signals can only be received between atomic actions of the python interpreter", presumably - and control will not return to Python unless something appears on the socket). Does anyone have a tip of a...
0
8680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9169
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9030
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8899
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7738
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.