signals

Are std::signal and std::raise thread-safe?

馋奶兔 提交于 2019-11-28 02:42:09
问题 The C and C++ standards support the concept of signal. However, the C11 standard says that the function signal() cannot be called in multi-threaded environments, or the behavior is undefined. But I think the signal mechanism is by nature for multi-threaded environments. A quote from the C11 standard 7.14.1.1.7 "Use of this function in a multi-threaded program results in undefined behavior. The implementation shall behave as if no library function calls the signal function." Any explanations

What does g_signal_connect_swapped() do?

谁说我不能喝 提交于 2019-11-28 02:28:31
问题 According to GObject reference g_signal_connect_swapped(instance, detailed_signal, c_handler, data); connects a GCallback function to a signal for a particular object. The instance on which the signal is emitted and data will be swapped when calling the handler. I don't quite get what this means. Does this mean that the data will point to the object pointed to by instance and instance will point to the object that was pointed to by data or am I making a mistake here? If former is the case

Using SIGINT

雨燕双飞 提交于 2019-11-28 02:21:34
问题 According to this http://www.cplusplus.com/reference/clibrary/csignal/signal.html SIGINT is generally used/cause by the user. How do i cause a SIGINT in c++? i seen an example using kill(pid, SIGINT); but i rather cause it another way. Also i am using windows. 回答1: C89 and C99 define raise() in signal.h: #include <signal.h> int raise(int sig); This function sends a signal to the calling process, and is equivalent to kill(getpid(), sig); If the platform supports threads, then the call is

Why does PySide implicitely create object members from class members for Signals?

不想你离开。 提交于 2019-11-28 02:05:58
On the PySide signals and slots page it says: "Signals are runtime objects owned by instances, they are not class attributes". Apparently the QObject constructor looks in the class attributes for Signals and copies them to the object instance. This is confirmed by my test program. from PySide import QtCore class Klass(QtCore.QObject): lst = [] sig = QtCore.Signal(str) def main(): obj1 = Klass() obj2 = Klass() print "id: obj1.lst = {}, obj1.sig = {}".format(id(obj1.lst), id(obj1.sig)) print "id: obj2.lst = {}, obj2.sig = {}".format(id(obj2.lst), id(obj2.sig)) print "id: klass.lst = {}, klass

write on closed connection doesn't generate sigpipe immediately

时光怂恿深爱的人放手 提交于 2019-11-28 02:01:53
问题 I've this problem with my server/client on C. If I close the server socket after a SIGINT, and then I try to write on this closed connection from the client, I've to do write two times before than client generates SIGPIPE. Shouldn't it generate it immediately? Is this a normal behaviour or something I need to fix? This is my code. I'm testing things on ubuntu, same PC, connecting via 127.0.0.1. server.c sigset_t set; struct sigaction sign; int sock_acc; int sock; void closeSig(){ close(sock

Need QGraphicsScene signal or event for _after_ change

≡放荡痞女 提交于 2019-11-28 01:23:00
I use QGraphicsScene of the Qt framework. Inside the scene I have some QGraphicsItem s which the user can select and move. I would like to have an info label where the current x and y coordinate of the currently moved selection (can consist of many items) is displayed. I have tried with the signal changed of QGraphicsScene . But it is fired before the x() and y() property of the items is set to the new values. So the labels always show the second-to-last coordinates. If one moves the mouse slowly, the display is not very wrong. But with fast moves and sudden stops, the labels are wrong. I need

Python signal don't work even on Cygwin?

百般思念 提交于 2019-11-28 01:19:09
问题 Python signal doesn't seem to work on Windows even if I run the python script inside Cygwin. I'm getting the AttributeError: 'module' object has no attribute SIGALRM Is there a way to go around this on Windows. I'm just running the example at the end of http://docs.python.org/2/library/signal.html 回答1: SIGALRM doesn't work in Windows. From the documentation: On Windows, signal() can only be called with SIGABRT, SIGFPE, SIGILL, SIGINT, SIGSEGV, or SIGTERM. A ValueError will be raised in any

Sending “ENTER” key through serial port

半腔热情 提交于 2019-11-28 01:00:19
问题 Hi I want to send some command to my device which is connected via serial port. How to send it? For example i found this on google search but for me it's useless. Control + E is a keyboard shortcut for 5, so: serial.Write(new byte[]{ 5 }, 0, 1); 回答1: The microsoft version of enter or new line is \r\n which is 0x0d 0x0a in hex. \r is the carriage return In a shell or a printer this would put the cursor back to the beginning of the line. \n is the line feed Puts the cursor one line below, in

What's the difference between various $SIG{CHLD} values?

僤鯓⒐⒋嵵緔 提交于 2019-11-28 00:56:36
问题 What is the difference between these settings? $SIG{CHLD} = 'IGNORE' $SIG{CHLD} = 'DEFAULT' $SIG{CHLD} = '' $SIG{CHLD} = undef According to "Advanced Programming in the UNIX Environment, 2nd edition", figure 10.1 the default value of SIGCHLD is "ignore." If "ignore" meant "SIG_IGN", then no child would ever be a zombie, and that's not the case. It doesn't get much more clear from there: If the process specifically sets its disposition to SIG_IGN, children of the calling process will not

Linux: Why is sig_atomic_t typedef'ed to int?

我怕爱的太早我们不能终老 提交于 2019-11-28 00:39:09
On my Linux box, sig_atomic_t is a plain old int . Do ints posses a special atomic quality? $ gcc -v Using built-in specs. Target: x86_64-linux-gnu ... Thread model: posix gcc version 4.3.2 (Debian 4.3.2-1.1) $ echo '#include <signal.h>' | gcc -E - | grep atomic typedef int __sig_atomic_t; typedef __sig_atomic_t sig_atomic_t; C99 sig_atomic_t conforms only to a very weak definition of "atomicity", because C99 has no concept of concurrency , only interruptibility. (C2011 adds a concurrency model, and with it the _Atomic types that make stronger guarantees; however, AFAIK sig_atomic_t is