signals

How to get signal strength of connected WiFi android?

白昼怎懂夜的黑 提交于 2019-11-27 15:22:46
问题 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

Trapping signals in a Swift command line application

浪子不回头ぞ 提交于 2019-11-27 15:19:01
How to capture different signals such as SIGINT and SIGTERM in Swift correctly? For example, when people stop my script by pressing Control - C , I want to do some cleanup before terminating it. Dispatch Sources can be used to monitor UNIX signals. Here is a simple example, a Swift 3 translation of the C code in the "Monitoring Signals" section from the Concurrency Programming Guide. import Dispatch // or Foundation signal(SIGINT, SIG_IGN) // // Make sure the signal does not terminate the application. let sigintSrc = DispatchSource.makeSignalSource(signal: SIGINT, queue: .main) sigintSrc

How to Handle SIGABRT signal?

给你一囗甜甜゛ 提交于 2019-11-27 15:14:00
Here is the code on which I set my handler for SIGABRT signal then I call abort() but handler does not get trigered, instead program gets aborted, why? #include <iostream> #include <csignal> using namespace std; void Triger(int x) { cout << "Function triger" << endl; } int main() { signal(SIGABRT, Triger); abort(); cin.ignore(); return 0; } PROGRAM OUTPUT: As others have said, you cannot have abort() return and allow execution to continue normally. What you can do however is protect a piece of code that might call abort by a structure akin to a try catch. Execution of the code will be aborted

Oracle Pro*C/OCI install handlers for SIGSEGV/SIGABRT and friends - why, and how to disable?

倾然丶 夕夏残阳落幕 提交于 2019-11-27 15:09:33
When using Pro*C (a embedded SQL preprocessor from Oracle for C-Code) or OCI I noticed that the connect/init routine installs some signal handlers. That means before a EXEC SQL CONNECT :username IDENTIFIED BY :password USING :dbspec ; or a OCIEnvNlsCreate() I can verify that for example those signals have following handlers: No NAME Pointer SA_SIGINFO SIG_DFL SIG_IGN ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― 1 SIGHUP (nil) false true false 2 SIGINT (nil) false true false 3 SIGQUIT (nil) false true false 4 SIGILL (nil) false true false 5 SIGTRAP (nil) false

How to handle a ctrl-break signal in a command line interface

别来无恙 提交于 2019-11-27 14:52:05
Before I begin, I want to clarify that this is not a command-line tool, but an application that accepts commands through it's own command-line interface. Edit: I must apologize about my explanation from before, apparently I didn't do a very good job at explaining it. One more time... I am building a command-line interface application that accepts commands from a user. I have a signal handler setup to catch the signals, which then sets a flag that I need to terminate the application. The problem I'm having is all of the console functions I can find are blocking, which means that I can't detect

Are sig_atomic_t and std::atomic<> interchangable?

孤者浪人 提交于 2019-11-27 14:24:14
As per the title. Can I use std::atomic<> in a signal handler or does sig_atomic_t provide other compiler features? n3376 1.9/6 When the processing of the abstract machine is interrupted by receipt of a signal, the values of objects which are neither — of type volatile std::sig_atomic_t nor — lock-free atomic objects (29.4) are unspecified during the execution of the signal handler, and the value of any object not in either of these two categories that is modified by the handler becomes undefined. Lock-free 29.4/1,2 The ATOMIC_..._LOCK_FREE macros indicate the lock-free property of the

How to debug programs using signals?

家住魔仙堡 提交于 2019-11-27 14:10:58
问题 #include <stdio.h> #include <signal.h> static volatile sig_atomic_t being_debugged = 1; static void int3_handler(int signo) { being_debugged = 0; } int main() { signal(SIGTRAP, int3_handler); __asm__ __volatile__("int3"); if (being_debugged) { puts("No, I don't want to serve you."); while (1) { /* endless loop */ ; } } puts("Yes, real routines go here."); return 0; } The above will give different output when run inside/outside gdb,because gdb captures the sigtrap signal. How to make my

Longjmp out of signal handler?

烂漫一生 提交于 2019-11-27 14:02:20
From the question: Is it good programming practice to use setjmp and longjmp in C? Two of the comments left said: "You can't throw an exception in a signal handler, but you can do a longjmp safely -- as long as you know what you are doing. – Dietrich Epp Aug 31 at 19:57 @Dietrich: +1 to your comment. This is a little-known and completely-under-appreciated fact. There are a number of problems that cannot be solved (nasty race conditions) without using longjmp out of signal handlers. Asynchronous interruption of blocking syscalls is the classic example." I was under the impression that signal

How does sig_atomic_t actually work?

橙三吉。 提交于 2019-11-27 13:34:10
How does the compiler or OS distinguish between sig_atomic_t type and a normal int type variable, and ensures that the operation will be atomic? Programs using both have same assembler code. How extra care is taken to make the operation atomic? sig_atomic_t is not an atomic data type. It is just the data type that you are allowed to use in the context of a signal handler, that is all. So better read the name as "atomic relative to signal handling". To guarantee communication with and from a signal handler, only one of the properties of atomic data types is needed, namely the fact that read and

Accurately reading of iPhone signal strength

杀马特。学长 韩版系。学妹 提交于 2019-11-27 13:19:59
There are a few questions on this already, but nothing in them seems to provide accurate results. I need to determine simply if the phone is connected to a cell network at a given moment. http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Reference/CTCarrier/Reference/Reference.html This class seems to be documented incorrectly, returning values for mobileCountryCode, isoCountryCode and mobileNetworkCode where no SIM is installed to the phone. carrierName indicates a 'home' network or a previous home network if the phone has been unlocked. I also looked up and found some