signals

Kill bash and child process

て烟熏妆下的殇ゞ 提交于 2019-12-11 11:07:40
问题 My C program executes commands in a bash shell. To do this, I fork and in the child process I run: char* command = "..."; /* provided by user */ execlp("/bin/bash", "bash", "-c", command, NULL); If this is a long running command, I would like to have the option of killing it. For example, say I'm doing: execlp("/bin/bash", "bash", "-c", "find / test", NULL); After this, I know the PID of the child that is executing bash, but bash is forking a separate process to execute find. $ ps aux | grep

When several signals arrive at a process, what is the order between the process handling the signals?

怎甘沉沦 提交于 2019-12-11 10:32:42
问题 When several signals arrives at a process, what is the order between the process handling the signals? What data structure is used to store the signals which have arrived at a process but not yet been delivered? For example, from APUE Since the process group is orphaned when the parentterminates, POSIX.1 requires that every process in the newly orphaned process group that is stopped (as our child is) be sent the hang-up signal (SIGHUP) followed by the continue signal (SIGCONT) This causes the

How to clean up local data in SIGINT handler

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 10:29:44
问题 I need to execute clean up functions in SIGINT handler, but I can't pass local data to it. Here an example: int main(int argc, char *argv[]) { struct database *db = db_cursor(); sockfd_t master_socket = init_server(); signal(SIGINT, sigint_handler); while (1) { // accepting connections } } void sigint_handler(int s) { destroy_db(db); shutdown(master_socket, SHUT_RDWR); close(master_socket); exit(EXIT_SUCCESS); } How can I implement such behaviour? I've tried make this variables are global,

How to convert spectral density to amplitude

喜你入骨 提交于 2019-12-11 10:29:40
问题 I have standard periodogram produced from the spectrum function call in the R "stats" package. It produces a spectral density on the Y axis. I wish to actually inspect the amplitude of the key frequency signals. How do i convert the spectral density to an amplitude? Is there a periodgram plot/analysis in R that produces a frequency vs amplitude plot automatically? Appreciate any advice. 回答1: Maybe you use different terminology than I do. The help page says that value returned from the

Don't want to remove terminated child process immediately, need to become zombie

无人久伴 提交于 2019-12-11 10:04:18
问题 I got below information from SE QUE Explicitly setting the disposition of SIGCHLD to SIG_IGN causes any child process that subsequently terminates to be immediately removed from the system instead of being converted into a zombie. As far I know, to read the child status it is required to have child pid in process table. So it is necessary to have zombie child process in process table to read the child status. So I want to write signal handler which will remove "setting the disposition of

system() function while SIGCHLD is ignored

眉间皱痕 提交于 2019-12-11 09:54:45
问题 Here is an example piece of my code signal(SIGCHLD, SIG_IGN); ret = system("ls -al"); if(ret < 0) { perror("system failed"); printf("return value is %d\n", ret); } The ls -al command can be executed without any problem. But the return value of system() is always -1. In this case, I can't get the real return value of the command. Some reference says that ignore SIGCHLD would affect waitpid() in system() , that's why system always returns -1. But what puzzles me more is that: isn't SIGCHLD

Custom signal not being handled by Scrapy internal API

ぐ巨炮叔叔 提交于 2019-12-11 09:44:41
问题 I am trying to handle a custom signal ' signalizers.item_extracted ' in a Scrapy extension 'MyExtension' which is successfully enabled when scrapy starts. Here is my code: signalizers.py # custom signals item_extracted = object() item_transformed = object() class MyExtension(object): def __init__(self): pass @classmethod def from_crawler(cls, crawler): # first check if the extension should be enabled and raise # NotConfigured otherwise if not crawler.settings.getbool('MYEXTENSION_ENABLED'):

Where is the uri of the new window, in create-web-view?

非 Y 不嫁゛ 提交于 2019-12-11 09:17:56
问题 According to the documentation, the create-new-window signal is called when a webkit is creating a new window. I've been trying to override this to handle <a target='_blank' links in PyGTK webkit browser. In a subclass of WebView I have: ... self.connect("create-web-view", self.newWin) ... def newWin(view, frame, data): print view.get_property('uri') print frame.get_property('uri') print data.get_property('uri') It is called when a new-window link is clicked, but for some reason all of these

Can I have one slot for several signals?

北城余情 提交于 2019-12-11 08:58:52
问题 I have several buttons, each with a Signal that emits one of their attributes (say, an integer) whenever the button is clicked. In a parent class, I'd like to be able to catch any of the buttons' emits and react based on that particular attribute from the button. I can think of a way to do that by individually 'connecting' each button in the parent class, but that seems wrong, and cumbersome, because in my application I add and remove buttons as part of the functionality. I'm probably

Stack frame for signal handling in the Linux Kernel

孤街醉人 提交于 2019-12-11 08:44:52
问题 I see that the stack frame the process needs to handle signals is allocated in the function setup_rt_frame() . My question is: where it is de-allocated? Thank you! 回答1: setup_rt_frame() sets stack for Real-time signals (see man 7 signal). It does 2 main things: Saves CPU context of user process (before it was interrupted) from kernel stack to user stack. For ARM architecture it's done in setup_sigframe(). Saves return address (where signal handler returns) to user stack. Return address will