Programming :: Possible To Connect A Signal Handler To A Variable?
Nov 1, 2010
Is it possible to connect a signal handler to a variable?So when the variable changes the signal handler is called.I have a vector containing strings which i want to parse when there are one or more available strings in the vector
Basically I'm intending to write serial RX signal handler.Application receives defined packages of data over serial which contains header and payload. Handler should analyse incoming stream and upon detection of header (header is 6B in length) switches to receive payload of length defined in header, then after receiving full message packs it and sends to application for handling.Problem I'm facing is that at random moments in signal I receive errors that "Resource temporarily unavailable" while reading from ttyOx device and I see that sometimes I miss incoming data.Also is it possible that if while I'm handling signal one more signal arrives and it is started to be handled parallel? If it is, what are the ways to prevent it? So I would be sure that no more signals will fire on same peripheral until I will finish handling what I have on my hands now.
Serial open and init: Code: Select allint open_port(int port_nr) { int fd; /* File descriptor for the port */ switch (port_nr) { case 1: fd = open("/dev/ttyO1", O_RDWR | O_NOCTTY | O_NDELAY); break;
locking mutex (phtread_t type) in a signal handler function (installed by function signal()) for Linux. It seems that if the mutex has been previously locked by another thread outside the signal handler function and then the signal handler function tries to lock it, the whole process hangs.
I'm new to Unix and every signal handler algorithm I've seen is more or less a copy of what I'm trying to do.[URL] designing a signal handler with sigwait in UNIX?
I'm trying to create a signal handler thread to handle SIGALRM signals. The main thread calls the following function before creating any other threads
Code:
pthread_t Timer::Init(long _clock_interval_musec) { // Set interval. clock_interval = _clock_interval_musec; // This is called while in a single threaded environment.
[code]....
clock_interval is 50.
Is the timer not firing? Did I not set my interval correctly? Did I not proper block the signals ensuring the that the default handler would not take care of them?
I have written a Linux kernel module (in Linux 2.4, Red Hat 9) which does the followings: It takes srcIP, sourceport, destIP, destport and loadvalue as command line arguments. If configured load value is greater than 1, it creates different channels (i.e. No of UDP channels created equals to configured load value), assign different source port and destination port to different channels and send UDP datagram in different channels. Say for example the configured parameters are as follows srcIP=10.17.17.43 destIP= 10.17.17.44 sourceport=10000 destport= 20000 loadvalue=2.
Then it creates two UDP different channels and transmits UDP packets (in every 20 milliseconds) to destination IP address (i.e., 10.17.17.44) with source port 10000, destination port 20000 in one channel and source port 10002, destination port 20000 in another channel. When I configure to pass ?loadvalue=500? and run the module, I get the below kernel panic message in system log file (i.e., var/log/messages) 0>Kernel panic: Aiee, killing interrupt handler! In interrupt handler - not syncing. Running the same linux kernel module ,in 1000 loadvalue, I get this message, eth0: Out-of-sync dirty pointer, 49937 vs. 49954 in text console. I am unable to catch the root cause of these problems and how will I solve these?
I'm trying to read content of file to variable and use this variable in for loop. The problem is, when I have c++ comment style in file - /*. Spaces in line are also interpreted as separated lines.
For example:
Code:
Changing $files to "$files" eliminate these problems but causes that whole content of variable is treated as one string (one execution of loop).
my script has a variable which comes in the form +00.00 +0.00 -00.00 or -0.00 (the numbers can be any in that form) for any that have a + symbol I need to remove the +, but if it has a - symbol it needs to stay.
i need to make a new variable with the string from the old variable btut without any plus sign. I have tried a lot of different ways with no success, each thing I tried either left the + or removed the entire string. I think this should work but doesn't
I want that I click with the mouse on the video, it paused.I notice that there is "BaconVideoWidget" which I guess is the video rendering widget but it don't have signal named "clicked":
I have Ubuntu 9.10 a dell laptop i am using a tew-644ub usb wireless adaptar and it's seeing signals but wont connect to any my network is unsecured and open. everytime i try it does this swirlly thing then says diconected. im using a diferent computer to post this so if there
I am using Debian linux. I have 100 timers running. If a timer expired which will generate a signal and it was mapped to a same function handler. All the timers are mapped to one function handler. The problem is if the timer expires one at a time, the function handler called at a time. But if the 2 timers expires at a time, the function handler is called one time only instead 2 times. Is it possible to invoke the function handler as many times based on timer expirary happens simultaneoulsy?
I am doing some Linux kernel programming for my research project. I need to record the timestamp (by using cpuid and rdtsc) when an interrupt handler (top half) is first invoked. Due to the time critical nature of the problem itself, I have to do the timestamping inside the interrupt handler itself (the first operation when the handler is called). However, I understand that tasks that are not so time critical should be deferred to a tasklet function (bottom half) for processing because other interrupts are disabled in a (top-half) interrupt handler. I am currently out of idea on how I can pass the timestamp information that I have obtained in the interrupt handler to the corresponding tasklet function.
My box: Dell Inspiron 1545. lspci results below. I have enabled the Broadcom STA restricted driver.Problems:1. I am noticing in Ubuntu (using Network Manager and Wicd) that I am unable to connect to wireless signals tha are very weak. In my other OS (dual boot), I am able to connect to these weak signals.2. And the speed of these networks is much slower, and the disconnect rate is much higher than in my other OSI am THRILLED with Ubuntu otherwise, just looking to fix this issue so I can use Ubuntu as my primary OS.Could this be an Broadcom STA issue, or Software config issue? etc? Obviously not hardware cause hardware is same on other OS.
Code: ~$ lspci 00:00.0 Host bridge: Intel Corporation Mobile 4 Series Chipset Memory Controller Hub (rev
I'm running ubuntu 10.10, in a Gateway M-6750. I can't get my wireless to work properly.
After I lose my wireless signal, I can't connect to a network again. I have to restart my computer or, remove the ndiswrapper module and insert it again so that I can connect to the network again.
I do this with:
Also, there are sometimes when the computer freezes up when trying to search for a signal.
I'm doing the shell history audit logging using syslog to gather the command history. I'm using this well publicized method using trap and logger:
declare -r REAL_LOGNAME=`/usr/bin/who am i | cut -d" " -f1` function log2syslog { declare command command=`fc -ln -0` logger -p local1.notice -t bash -i ": $REAL_LOGNAME as $LOGNAME :$command" } trap log2syslog DEBUG TERM
The problem is that the trap on DEBUG will catch the next to last command executed (by virtue of the "fc" command) which is not the current command executed. TERM will catch that "next to last" command on exit, thus completing the logging of each command executed during that session.
However, CTL+D doesn't seem to emit a SIGTERM signal. What signal is actually being emitted and can it be trapped? I guess another question would be whether there is a way to trap history after command line execution? Moving to Bash 4.1 isn't possible in our "supported" multi-platform environment
I have created a pthread, and installed a signal handler inside that, same way as we do in main( ) function. The thread's signal handler is a separate function. Surprisingly, it is not working, that is the thread's signal handler is not able to catch signals. Here is the code:
I have a Socket library, written in C++, in which the method used to send data never has the opportunity to handle an errno of SIGPIPE. Thus I thought perhaps I should setup a signal handler to receive the signal, but this too is not being called.Is there something that I am missing or doing that is completely wrong? Below is the relevant code. Note that a SIGPIPE signal is generated when the Server is unable to send data to the Client (e.g. the client has terminated).Server code:
I have Lenovo SL500 with ubuntu 10.10. Also i have installed latest GeForce 9300M GS drivers from NVIDIA site. NVTV is also installed. When i want to connect to LG 32LE4500 trough HDMI i get no singnal message. I tried to configure with nvidia-settings but no positive results. Also i have tried with bigger SAMSUNG screen but no results... am i doing something wrong? Or, is this problem with NVIDIA (or ubuntu) HDMI support. If it is, where can i find information when will be bigger support for HDMI with NVIDIA and ubuntu?
I have a signal handler in my tool, which is registered and used between some particular interval (i am using timer). Now this signal handler should NOT allow any other handler to be registered or invoked after this handler is once registered. Is there any way to accomplish this?
I am writing a bash script where I need standard Input should be saved in a file and should be terminated by passing CTRL+D signal. Any clue how can I do that in bash script.
e.g. Enter one line at a time Press CTRL+D to finish
But unable to catch the SIGTERM signal if I do shutdown, as man pages says shutdown genrates the SIGTERM and SIGKILL signals, but we cant handle the SIGKILL signal. My code is working fine if I genrate the SIGTERM signal by Kill command, and also for SIGINT signgal genrated from the CTRL+c key.
Here is my code:
/* Example of using sigaction() to setup a signal handler with 3 arguments * including siginfo_t. */ #include <stdio.h> #include <unistd.h> #include <signal.h> #include <string.h>
I was trying to program using fork(). The objective of this code is to
1. I am activating a process A - SubSuctionMotors. 2. Process A is going to stop with either of this condition a) Switch is activated - swret=1 b) Time allowed has expired 3. Stop the process A.
[Code]...
1. We purposely force the switch to be inactive to test the child process (timer), whether after 2 seconds the motor stop. It turns out to be successful in first few attempts. After some while, the program hang, nothing is executed anymore and the program is not exit or terminated. What can cause the program to hang?
2. We tried to stop motor by switch activation (if the switch is to be successfully activated, the time it takes will always be shorter than the timer allowed time). However, the program did not seems like noticing the switch has been activated, and it just stop the motor according to timer. Why it behave this way?
I'm just beginning to program with GTK+, and I'm facing this issue: I want to inhibit a signal emission inside one and only one function. I've down cut my code into the smallest example I can to show you what I want to do:The "Emitter" contains a "GtkSpinBox" and it relays the "value-changed" signal, it's header: