signals

Sending information with a Signal in Linux

我们两清 提交于 2020-01-01 05:41:05
问题 When sending a signal from one process to another, I also want to send a value of type long . Is that possible? I am using SIGUSR1. 回答1: Sure you can, but you'll have to send it with sigqueue(2) instead of kill(2) . And you can send an int or a sival_ptr . union sigval { int sival_int; void *sival_ptr; }; Establish the handler struct sigaction sa; sigemptyset(&sa.sa_mask); sa.sa_sigaction = handler; sa.sa_flags = SA_SIGINFO; /* Important. */ sigaction(SIGUSR1, &sa, NULL); The handler for a

Sending information with a Signal in Linux

孤者浪人 提交于 2020-01-01 05:41:01
问题 When sending a signal from one process to another, I also want to send a value of type long . Is that possible? I am using SIGUSR1. 回答1: Sure you can, but you'll have to send it with sigqueue(2) instead of kill(2) . And you can send an int or a sival_ptr . union sigval { int sival_int; void *sival_ptr; }; Establish the handler struct sigaction sa; sigemptyset(&sa.sa_mask); sa.sa_sigaction = handler; sa.sa_flags = SA_SIGINFO; /* Important. */ sigaction(SIGUSR1, &sa, NULL); The handler for a

In detail, what happens when you press Ctrl-C in a terminal?

谁说我不能喝 提交于 2020-01-01 05:33:07
问题 In detail, what happens when you press Ctrl-C in a terminal? Yes, I know that it sends SIGINT, but what steps does it take to get there? I have done some research so I think I understand most of the picture, but not all of it. For the sake of pedagogy, I will assume we are running a terminal emulator, xterm, in an X session. The terminal is running the Bash shell, and the shell is currently running some long running pipeline consisting of multiple processes in the foreground. I press Ctrl-C

Programmatically getting the iPhone's carrier signal strength

孤人 提交于 2020-01-01 05:14:05
问题 Is there a way to get the iPhone's carrier, and/or the current signal strength, using Objective-C? I know how to determine if a data connection is present, and whether or not that connection is wi-fi vs. cellular. I also know that you can manually place the iPhone into "field test" mode by going to the phone app, and dialing #3001*12345*# and hitting Send. 回答1: You made me curious and I found out that it's actually *3001#12345#* (hashes and stars exchanged). 回答2: This probably won't pass

Externally disabling signals for a Linux program

谁都会走 提交于 2020-01-01 04:23:26
问题 On Linux, is it possible to somehow disable signaling for programs externally ... that is, without modifying their source code? Context: I'm calling a C ( and also a Java ) program from within a bash script on Linux. I don't want any interruptions for my bash script, and for the other programs that the script launches (as foreground processes). While I can use a... trap '' INT ... in my bash script to disable the Ctrl C signal, this works only when the program control happens to be in the

FATAL SIGNAL 11 (Sigsegv) at 0x00000000 (code=1)?

半城伤御伤魂 提交于 2019-12-31 12:51:40
问题 Why does this problem occur? public static String path; private VideoView mVideoView; mVideoView = (VideoView) findViewById(R.id.surface_view); mVideoView.setVideoPath(path); mVideoView.setMediaController(new MediaController(this)); mVideoView.requestFocus(); //... private int mLayout = VideoView.VIDEO_LAYOUT_ZOOM; @Override public void onConfigurationChanged(Configuration newConfig) { if (mVideoView != null) mVideoView.setVideoLayout(mLayout, 0); super.onConfigurationChanged(newConfig); }

Signal handling and sigemptyset()

眉间皱痕 提交于 2019-12-31 10:22:38
问题 Could anyone please explain in a really easy way to understand what sigemptyset() does? Why is it useful? I've read a bunch of definitions but i just don't understand. From what i gather it tracks the signals that are being used for blocking purposes? I'm not really sure i understand why that would be useful. Is it so we do not get that specific signal recursively? Basic example where sigemptyset() is used: #include <signal.h> #include <stdio.h> #include <unistd.h> int main(){ struct

Signal handling and sigemptyset()

旧街凉风 提交于 2019-12-31 10:22:07
问题 Could anyone please explain in a really easy way to understand what sigemptyset() does? Why is it useful? I've read a bunch of definitions but i just don't understand. From what i gather it tracks the signals that are being used for blocking purposes? I'm not really sure i understand why that would be useful. Is it so we do not get that specific signal recursively? Basic example where sigemptyset() is used: #include <signal.h> #include <stdio.h> #include <unistd.h> int main(){ struct

How to use SIGFPE with signal?

丶灬走出姿态 提交于 2019-12-31 06:59:06
问题 I just informed myselve about "signals" in C/C++ and played around. But i have a problem to understand the logic of SIGFPE . I wrote a little program which will run into a division by zero, if this happens then the signal should be triggered and the signal handler should be executed. But instead my program just crashes. So what is the purpose of the SIGFPE if it does not even work on division by zero? #include <stdio.h> #include <signal.h> #include <iostream> int signal_status = 0; void my

Is there a way to make my program work with less code?

十年热恋 提交于 2019-12-31 05:22:09
问题 I wrote the following code for a school assignment - It compiles and prints all the correct messages. But just for my own curiosity, I would like to know if my code can be shorten and still works. I tried "signal" instead of "sigaction", but I heard that "sigaction" is strongly preferred over "signal". Also, this assignment requires 3 handlers. Can someone take a look and give me some tips? Thank you! #define _POSIX_SOURCE #define _BSD_SOURCE #include <stdio.h> #include <signal.h> #include