signals

Unix/Linux: Handler of SIGCONT/SIGTSTP

蓝咒 提交于 2019-12-11 17:40:22
问题 I'm currently writting program using signals, and I've got this trouble: How can I change state of executing program to stopped/running without sending SIGSTOP / SIGCONT ? I understand, that I need to use: void add_to_runqueue (struct task_struct * p) and void del_from_runqueue (struct task_struct * p) but how to obtain structure task_struct of currently running process? Also: if it is all that I need to do (calling those 2 functions). Thanks in advance! 回答1: These functions would be kernel

Using Both Conditional Variables & Mutex to Synchronize Threads in C

天涯浪子 提交于 2019-12-11 17:24:23
问题 Edited as per commenter's request. This program creates two threads. Each thread reads from one of two specific input files, each of which contains either one letter or one '0' per line of code. The threads are supposed to read the letters into a global char array, which is then printed. The problem is that, upon reaching a '0,' the active thread must transfer control to the other thread, which should not have a '0' on that line. (We are sure that, if File 1 has a '0' on a line, then File 2,

how to know the fundamental frequency is right detected by fft/lomb-scargle?

随声附和 提交于 2019-12-11 16:31:36
问题 I am using two methods,fft and lomb-scargle, to find periods for a timing sequence points. However the fundamental frequency changes much even for the same dataset. I can get the right result only when I fine tune the sampling rate.<>br/ How to choose the parameters of the two methods to get a consistent fundamental frequency. How to know the result is reliable? 回答1: The recent "Understanding the Lomb-Scargle Periodogram - Jacob T. VanderPlas" that you can find on This link to arxiv is a very

Detect whether tracee is in a signal handler when using ptrace

南楼画角 提交于 2019-12-11 16:26:09
问题 I test that on Linux and it seems that when the tracee is in a signal handler, the tracer can use ptrace() to attach to it, as usual. But since tracee is in a signal handler, some functions might not be OK to invoke because of the asyn-signal-safe problem. So, is there any methods to detect that situation after calling ptrace()? 回答1: This recent discussion may interest you. The short answer is that you can tell whether inferior (tracee) is in a signal handler by unwinding its stack, and

Python LIRC blocking Signal workaround not working

纵然是瞬间 提交于 2019-12-11 16:16:05
问题 I've been having trouble with the Python LIRC function lirc.nextcode() . I turned off blocking, which allows the code lirc.nextcode() to be skipped if the LIRC queue is empty, by initializing with lirc.init("program", blocking=False) and tried lirc.set_blocking(False, sockid) . Neither worked and the code would always hang, waiting for a button press, when it should continue on. I found this workaround that puts a time limit on raw_input('prompt') . So even if my lirc.nextcodde() waits for a

Calling SysV msgsnd from signal handler

老子叫甜甜 提交于 2019-12-11 15:56:19
问题 Is it safe to invoke msgsnd function from signal handler? Code for our services is not intended to every gracefully complete, so I don't have exit point, however I need to send message to another process when services is stopped, so I need to catch SIGTERM and perform msgsnd before calling exit(0). Is that safe? I looked into signal safety manual page and did not found msgsnd in the list. Should I consider this as unsafe function? What are the possible consequences? 回答1: No, it's not safe.

kill is unsafe respect to signals - any alternative?

試著忘記壹切 提交于 2019-12-11 15:18:33
问题 I read that kill is unsafe respect to signals here. What else should I use if I want to kill child process as part of clean up inside my signal handler? What are my alternatives? 回答1: You've misread, that page says that kill() (and everything else in the table) shall be async-signal-safe. anything not in the table is to be considered unsafe. 来源: https://stackoverflow.com/questions/6971201/kill-is-unsafe-respect-to-signals-any-alternative

Handling signals SIGSTP, SIGCONT, SIGINT with child process

删除回忆录丶 提交于 2019-12-11 14:56:43
问题 I'm currently writing a simple shell in C and i'm facing issues with signals. For example when I launch my program, I type ping command then CTRL-Z I want that the child process (the ping command) to be paused and then to come back when I use fg. I think that I need to store as a global variable the child pid of the one that execute the ping command. I already checked other posts to resolve the problem by my own but I can't get it working. This is the code to execute a command (multiple

How to redirect signal to child process from parent process?

℡╲_俬逩灬. 提交于 2019-12-11 14:54:35
问题 I am trying to understand processes in C. I currently want to create shell-like structure which - after pressing a shortcut like Ctrl + C or Ctrl + Z will kill all its subprocesses but will stay alive. My code looks like this: #include <ctype.h> #include <errno.h> #include <stdbool.h> #include <stdio.h> #include <readline/readline.h> #include <readline/history.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <signal.h> #include <sys/wait.h> #include <termios.h>

Convolution & Deconvolution using Scipy

为君一笑 提交于 2019-12-11 14:37:07
问题 I am trying to compute Deconvolution using Python. I have a signal let say f(t) which is the convoluted by the window function say g(t). Is there some direct way to compute the deconvolution so I can get back the original signal? For instance f(t) = exp(-t**2/3); Gaussian function and g(t) = Trapezoidal function Thanks in advance for your kind suggestion. 回答1: Is this an analytical or numerical problem? If it's numerical, use scipy.signal.devconvolve: http://docs.scipy.org/doc/scipy/reference