signals

Using SIGINT

送分小仙女□ 提交于 2019-11-29 08:35:24
According to this http://www.cplusplus.com/reference/clibrary/csignal/signal.html SIGINT is generally used/cause by the user. How do i cause a SIGINT in c++? i seen an example using kill(pid, SIGINT); but i rather cause it another way. Also i am using windows. C89 and C99 define raise() in signal.h: #include <signal.h> int raise(int sig); This function sends a signal to the calling process, and is equivalent to kill(getpid(), sig); If the platform supports threads, then the call is equivalent to pthread_kill(pthread_self(), sig); The return value is 0 on success, nonzero otherwise. Jon You

How to block all SIGNALS in thread WITHOUT using SIGWAIT?

南楼画角 提交于 2019-11-29 08:32:31
问题 I have a main application that spawns a seperate thread to process messages off a queue. I have an issue on AIX when I hit CTRL-C as it seems to make some "connection handles" in the thread become invalid. I do have a shutdown hook in the main program catching the SIGINT but on AIX it seems to somehow send a signal to the thread as well...although that is not really possible from what I hear... Essentially I would like to know if I want the MAIN application to handle ALL signals I am

Python signal don't work even on Cygwin?

杀马特。学长 韩版系。学妹 提交于 2019-11-29 07:55:00
Python signal doesn't seem to work on Windows even if I run the python script inside Cygwin. I'm getting the AttributeError: 'module' object has no attribute SIGALRM Is there a way to go around this on Windows. I'm just running the example at the end of http://docs.python.org/2/library/signal.html tiago SIGALRM doesn't work in Windows. From the documentation : On Windows, signal() can only be called with SIGABRT, SIGFPE, SIGILL, SIGINT, SIGSEGV, or SIGTERM. A ValueError will be raised in any other case. This question addresses the topic of getting a SIGALRM equivalent in Windows. And this

C SIGSEGV Handler & Mprotect

孤人 提交于 2019-11-29 07:54:43
I'm constructing a program which uses mprotect() to restrict a block of memory from accessing. When the memory is requested, a SIGSEGV is thrown which I listen for using a signal() call. Once the SIGSEGV has been detected, I need to somehow access the pointer to the memory that was requested (that threw the fault) and the size of the segment requested. Is this possible? void fifoSigHandler(){ // Needs to only remove protection from requested block of virtual memory mprotect(fifoVm,(size_t)fifoVm_size,PROT_WRITE); printf("Caught Seg Fault"); } void fifo_init(void* vm, int vm_size, int n_frames,

Sending “ENTER” key through serial port

ⅰ亾dé卋堺 提交于 2019-11-29 07:35:22
Hi I want to send some command to my device which is connected via serial port. How to send it? For example i found this on google search but for me it's useless. Control + E is a keyboard shortcut for 5, so: serial.Write(new byte[]{ 5 }, 0, 1); matthias.lukaszek The microsoft version of enter or new line is \r\n which is 0x0d 0x0a in hex. \r is the carriage return In a shell or a printer this would put the cursor back to the beginning of the line. \n is the line feed Puts the cursor one line below, in some shells this also puts the cursor to the beginning of the next line. a printer would

Pausing a process?

☆樱花仙子☆ 提交于 2019-11-29 06:21:56
Is there a way to pause a process (running from an executable) so that it stops the cpu load while it's paused, and waits till it's unpaused to go on with its work? Possibly in python, or in some way accessible by python. By using psutil ( https://github.com/giampaolo/psutil ): >>> import psutil >>> somepid = 1023 >>> p = psutil.Process(somepid) >>> p.suspend() >>> p.resume() you are thinking of SIGTSTP -- the same signal that happens when you push CTRL-Z . This suspends the process until it gets SIGCONT . of course, some programs can just catch and ignore this signal, so it depends on the

Accessing the user's request in a post_save signal

情到浓时终转凉″ 提交于 2019-11-29 06:05:28
问题 I have done the below post_save signal in my project. from django.db.models.signals import post_save from django.contrib.auth.models import User # CORE - SIGNALS # Core Signals will operate based on post def after_save_handler_attr_audit_obj(sender, **kwargs): print User.get_profile() if hasattr(kwargs['instance'], 'audit_obj'): if kwargs['created']: kwargs['instance'].audit_obj.create(operation="INSERT", operation_by=**USER.ID**).save() else: kwargs['instance'].audit_obj.create(operation=

Passing arguments django signals - post_save/pre_save

倖福魔咒の 提交于 2019-11-29 05:59:34
问题 I am working on a notification app in Django 1.6 and I want to pass additional arguments to Django signals such as post_save . I tried to use partial from functools but no luck. from functools import partial post_save.connect( receiver=partial(notify, fragment_name="categories_index"), sender=nt.get_model(), dispatch_uid=nt.sender ) notify function has a keyword argument fragment_name which I want to pass as default in my signals. Any suggestions? 回答1: Your attempt with partial isn't working

How to stop python from propagating signals to subprocesses?

狂风中的少年 提交于 2019-11-29 05:32:20
I'm using python to manage some simulations. I build the parameters and run the program using: pipe = open('/dev/null', 'w') pid = subprocess.Popen(shlex.split(command), stdout=pipe, stderr=pipe) My code handles different signal. Ctrl+C will stop the simulation, ask if I want to save, and exit gracefully. I have other signal handlers (to force data output for example). What I want is to send a signal (SIGINT, Ctrl+C) to my python script which will ask the user which signal he wants to send to the program. The only thing preventing the code to work is that it seems that whatever I do, Ctrl+C

Drawing sine wave with increasing Amplitude and frequency over time

混江龙づ霸主 提交于 2019-11-29 05:13:28
I am trying to plot a sine wave where the amplitude increases over time and the frequecy increases over time as well. I draw a normal sine wave as shown below but I couldn't change the amplitude and frequency. Any Ideas? t = [ 0 : 1 : 40 ]; % Time Samples f = 500; % Input Signal Frequency fs = 8000; % Sampling Frequency x = sin(2*pi*f/fs*t); % Generate Sine Wave figure(1); stem(t,x,'r'); % View the samples figure(2); stem(t*1/fs*1000,x,'r'); % View the samples hold on; plot(t*1/fs*1000,x); % rayryeng I believe what you are speaking of is amplitude modulation (AM) and frequency modulation (FM)