signals

About the delivery of standard signals

笑着哭i 提交于 2019-11-29 04:52:20
By contrast, if multiple instances of a standard signal are delivered while that signal is currently blocked , then only one instance is queued. I think the above description is not so clear and causing ambiguity to me: what if the specific signal is not blocked , will multiple instances of the same signal be queued? Where is the signal queued,a process specific location or a global location? How is the queued signals handled, will it be possible that two signals are being processed at the same time,or it's guaranteed signals will be processed one by one? So it's actually 3 questions here..

Django post save signal getting called twice despite uid

被刻印的时光 ゝ 提交于 2019-11-29 04:21:24
I have registered my signal with the callback using the @receiver decorator @receiver(post_save, sender=User, dispatch_uid='ARandomUniqueString') def do_callback(sender, **kwargs): I have put the from app.signals import * code in __init__.py and I can see that it gets imported twice and I do not think there is a good way to fix it, possibly happening due to installed apps in settings.py . I cannot understand why despite using dispatch_uid and the modelInstance.save being invoked only once, it still runs do_callback twice. Any suggestions? Ok so I moved the import to views.py (or models.py and

Go: Get signal origin

烂漫一生 提交于 2019-11-29 04:14:56
I'm using Go to launch a couple of scripts and when they have some problems they use the "alert" signal, I know Go can capture those signals but I need to know the PID that originated the Signal. in C to the signal handler is passed a structure to know the pid who originated the signal but in Go looks like is not the case package main import ( "fmt" "os" "os/signal" ) func main() { c := make(chan os.Signal, 1) signal.Notify(c, os.Interrupt, os.Kill) s := <-c fmt.Println("Got signal:", s) fmt.Printf("%+v\n",s) } the example below (extracted from the signal doc) send me the signal who originated

catching SIGINT in a multithreaded program

夙愿已清 提交于 2019-11-29 02:22:37
I am writing a multithreaded program where I want to handle a possible Ctrl-C command from the user to terminate execution. As far as I know there is no guarantee that the main thread, which is able to cancel every working thread, will catch the signal. Is it, therefore, necessary to have a different signal handler to the code of the working thread so that anyone will catch the signal if it arrives, or is there another way to do that with having a signal handler only in the main thread's code? You can block signals from the calling thread with pthread_sigmask(). And, as the blocked signals are

Signal handlers and logging in Python

心不动则不痛 提交于 2019-11-29 02:01:26
Documentation for logging module says that If you are implementing asynchronous signal handlers using the signal module, you may not be able to use logging from within such handlers. This is because lock implementations in the threading module are not always re-entrant, and so cannot be invoked from such signal handlers. This suggests that one should not make logging calls from the code invoked by the signal handler directly or indirectly. If you do once in a while program will be left is a state when only kill -9 helps. Important question for me now is following. Can this locking problem also

Is there any way to create a user defined signal in Linux?

孤人 提交于 2019-11-29 01:58:05
Is there any way to create a user defined signals in Linux? My signal (signal number) should not match any of the existing signal numbers. In other words, i want to create my own unique signal, which will be registered and caught by my handler. Is it possible? If yes, how? Thanks in advance. You can't add or register your own SIGWHATEVER. See sigset_t , it is fixed size. See valid_signal() beartraps. SIGRTMIN through SIGRTMAX (these are not normally constants but macros which expand to functions evaluated at runtime) are available for whatever use you like, as are SIGUSR1 and SIGUSR2 . The

Can a C program continue execution after a signal is handled?

别等时光非礼了梦想. 提交于 2019-11-29 01:45:42
I'm new at signal handling in Unix through C and I have been looking at some tutorials on it (out of pure interest). My questions is, is it possible to continue execution of a program past the point where a signal is handled? I understand that the signal handling function does the cleanup but in the spirit of exception handling (such as in C++), is it possible for that signal to be handled in the same fashion and for the program to continue running normally? At the moment catch goes in an infinite loop (presumably a way to quit would be to call exit(1) ). My intention would be for b to be

catching signals while reading from pipe with select()

别等时光非礼了梦想. 提交于 2019-11-29 01:14:15
问题 using select() with pipe - this is what I am doing and now I need to catch SIGTERM on that. how can I do it? Do I have to do it when select() returns error ( < 0 ) ? 回答1: First, SIGTERM will kill your process if not caught, and select() will not return. Thus, you must install a signal handler for SIGTERM . Do that using sigaction() . However, the SIGTERM signal can arrive at a moment where your thread is not blocked at select() . It would be a rare condition, if your process is mostly

How to propagate a signal through a collection of scripts?

99封情书 提交于 2019-11-29 01:13:26
I have an collection of scripts which are controlled by a main one. I want to trap the signal ctrl + c in the main script and propagate it to the others. The other scripts should trap this signal as well ( from the main script ) and do some clean-up ... I have tried to send kill -s SIGINT to the children, but they seem they are unable to catch the signal( even if trap 'Cleanup' SIGINT being defined on the children scripts ) Any clues how to realize this? The following example demonstrates a parent script that does something ( sleep 5 ) after it starts two children that do their own thing (also

How to get signal strength of connected WiFi android?

半世苍凉 提交于 2019-11-29 00:37:10
I want to get signal strength of this wifi which is connected with my device. This is probably easy. But I am beginner. And It's homework. How to get it? I tried this code. But it doesn't work. registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { final WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); int state = wifi.getWifiState(); if(state == WifiManager.WIFI_STATE_ENABLED) { List<ScanResult> results = wifi.getScanResults(); for (ScanResult result : results) { if(result.BSSID.equals(wifi.getConnectionInfo()