Sponsored Content
Full Discussion: how to trap signals.
Top Forums UNIX for Advanced & Expert Users how to trap signals. Post 9493 by jyotipg on Monday 29th of October 2001 03:02:22 AM
Old 10-29-2001
changed approach

hi!,
I have chosen a different approach to my previous problem. I have added a signal handler to my C code which traps the signals occuring in any instance of my application and writes to a central log file.. which I keep on grep-ing through a script for further action. but, I am just dont have any idea about how make things happen by my first approach. any ideas to gimme any insight about how to proceed in the problem would be anxiously awaited.
Smilie
 

10 More Discussions You Might Find Interesting

1. Programming

Signals In HP-UX

does the way of handling, interrupting signals in HP-UX same as that of solaris. If there is difference than what it is.?:confused: (1 Reply)
Discussion started by: kapilv
1 Replies

2. Shell Programming and Scripting

Building a better mouse trap, or How many lines of code does it take to trap a mouse?

Hello all, I'm hoping to get a little insight from some of the wily veterans amongst you. I've written a script to check for new outgoing files to our vendors located on our ssl server. It seems to be working ok, but the final question here, will be one of logic, and/or a better way to... (4 Replies)
Discussion started by: mph
4 Replies

3. Shell Programming and Scripting

Cntl+z Trap is not detecting ??? Help required to add a trap detection ???

Hi folks, I have tried to add some trap detection in the below script....this script is used to monitor database activities...in a rather awkward way :rolleyes:.... The idea behind adding trap is that....this script creates lots of temporary files in the running folder to store the count... (1 Reply)
Discussion started by: frozensmilz
1 Replies

4. UNIX for Dummies Questions & Answers

Signals...

(posted this in the scripting forum as well, but figured it should go here) So, what's going on is this: For our program, we had to create our own shell, and if the user pressed ctrl-c just at the cmdline, then this signal would be ignored, but if there is a foreground process running, let's... (0 Replies)
Discussion started by: blind melon
0 Replies

5. Programming

Using Signals

How can use signals in a C program If i want a child program to signal it's parent program that it(child) program has completed the task that it was assigned.:confused: (2 Replies)
Discussion started by: kapilv
2 Replies

6. Shell Programming and Scripting

how trap the signals in shell scripting

Hi all, I have the c program that c program has to be in sleep mode. I want write a script the it should trap the signal from the c program. The signals are sighup,sigkill,sigterm,sigchld and then it has to go to sleep. If signal is sigchld it has to do to some function. My question is how to... (3 Replies)
Discussion started by: bhas85
3 Replies

7. Homework & Coursework Questions

VM trap may work differently than a pure install trap.

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: That is the last reply I received from my instructor, and I'm looking for some alternatives. When using... (2 Replies)
Discussion started by: newuser45
2 Replies

8. UNIX for Advanced & Expert Users

Help with Signals

Hi All, The problem statement is as below: Problem: A process (exe) is getting executed in background. The output of this process is getting logged in a file. After successfully running for some time the process gets terminated. In the log file following is present: ^M[7m Interrupt ^M[27m... (8 Replies)
Discussion started by: Praty.27
8 Replies

9. Shell Programming and Scripting

Help with trap and signals

I am having issues with trap not working inside a script. I am currently trying this on a Knoppix system V 5.1. What I would like to happen is when I press control c, a message gets echoed and the script is ended. For example: #! /bin/bash trap "echo CTRL c was pressed ; break" SIGINT... (11 Replies)
Discussion started by: Basherrr
11 Replies

10. Shell Programming and Scripting

Reg trap signals

let LIMIT=50 function check { if ]; then print LIMIT OK else print "LIMIT changed!" fi } trap check DEBUG print $LIMIT LIMIT=$((LIMIT + 30)) trap - DEBUG Can anyone tell me how debugging is accomplished?? (4 Replies)
Discussion started by: Karthick N
4 Replies
Tcl_AsyncCreate(3)					      Tcl Library Procedures						Tcl_AsyncCreate(3)

__________________________________________________________________________________________________________________________________________________

NAME
Tcl_AsyncCreate, Tcl_AsyncMark, Tcl_AsyncInvoke, Tcl_AsyncDelete, Tcl_AsyncReady - handle asynchronous events SYNOPSIS
#include <tcl.h> Tcl_AsyncHandler Tcl_AsyncCreate(proc, clientData) Tcl_AsyncMark(async) int Tcl_AsyncInvoke(interp, code) Tcl_AsyncDelete(async) int Tcl_AsyncReady() ARGUMENTS
Tcl_AsyncProc *proc (in) Procedure to invoke to handle an asynchronous event. ClientData clientData (in) One-word value to pass to proc. Tcl_AsyncHandler async (in) Token for asynchronous event handler. Tcl_Interp *interp (in) Tcl interpreter in which command was being evaluated when handler was invoked, or NULL if handler was invoked when there was no interpreter active. int code (in) Completion code from command that just completed in interp, or 0 if interp is NULL. _________________________________________________________________ DESCRIPTION
These procedures provide a safe mechanism for dealing with asynchronous events such as signals. If an event such as a signal occurs while a Tcl script is being evaluated then it is not safe to take any substantive action to process the event. For example, it is not safe to evaluate a Tcl script since the interpreter may already be in the middle of evaluating a script; it may not even be safe to allocate mem- ory, since a memory allocation could have been in progress when the event occurred. The only safe approach is to set a flag indicating that the event occurred, then handle the event later when the world has returned to a clean state, such as after the current Tcl command completes. Tcl_AsyncCreate, Tcl_AsyncDelete, and Tcl_AsyncReady are thread sensitive. They access and/or set a thread-specific data structure in the event of a core built with --enable-threads. The token created by Tcl_AsyncCreate contains the needed thread information it was called from so that calling Tcl_AsyncMark(token) will only yield the origin thread into the asynchronous handler. Tcl_AsyncCreate creates an asynchronous handler and returns a token for it. The asynchronous handler must be created before any occur- rences of the asynchronous event that it is intended to handle (it is not safe to create a handler at the time of an event). When an asyn- chronous event occurs the code that detects the event (such as a signal handler) should call Tcl_AsyncMark with the token for the handler. Tcl_AsyncMark will mark the handler as ready to execute, but it will not invoke the handler immediately. Tcl will call the proc associated with the handler later, when the world is in a safe state, and proc can then carry out the actions associated with the asynchronous event. Proc should have arguments and result that match the type Tcl_AsyncProc: typedef int Tcl_AsyncProc( ClientData clientData, Tcl_Interp *interp, int code); The clientData will be the same as the clientData argument passed to Tcl_AsyncCreate when the handler was created. If proc is invoked just after a command has completed execution in an interpreter, then interp will identify the interpreter in which the command was evaluated and code will be the completion code returned by that command. The command's result will be present in the interpreter's result. When proc returns, whatever it leaves in the interpreter's result will be returned as the result of the command and the integer value returned by proc will be used as the new completion code for the command. It is also possible for proc to be invoked when no interpreter is active. This can happen, for example, if an asynchronous event occurs while the application is waiting for interactive input or an X event. In this case interp will be NULL and code will be 0, and the return value from proc will be ignored. The procedure Tcl_AsyncInvoke is called to invoke all of the handlers that are ready. The procedure Tcl_AsyncReady will return non-zero whenever any asynchronous handlers are ready; it can be checked to avoid calls to Tcl_AsyncInvoke when there are no ready handlers. Tcl calls Tcl_AsyncReady after each command is evaluated and calls Tcl_AsyncInvoke if needed. Applications may also call Tcl_AsyncInvoke at interesting times for that application. For example, Tcl's event handler calls Tcl_AsyncReady after each event and calls Tcl_AsyncInvoke if needed. The interp and code arguments to Tcl_AsyncInvoke have the same meaning as for proc: they identify the active interpreter, if any, and the completion code from the command that just completed. Tcl_AsyncDelete removes an asynchronous handler so that its proc will never be invoked again. A handler can be deleted even when ready, and it will still not be invoked. If multiple handlers become active at the same time, the handlers are invoked in the order they were created (oldest handler first). The code and the interpreter's result for later handlers reflect the values returned by earlier handlers, so that the most recently created handler has last say about the interpreter's result and completion code. If new handlers become ready while handlers are executing, Tcl_AsyncInvoke will invoke them all; at each point it invokes the highest-priority (oldest) ready handler, repeating this over and over until there are no longer any ready handlers. WARNING
It is almost always a bad idea for an asynchronous event handler to modify the interpreter's result or return a code different from its code argument. This sort of behavior can disrupt the execution of scripts in subtle ways and result in bugs that are extremely difficult to track down. If an asynchronous event handler needs to evaluate Tcl scripts then it should first save the interpreter's state by calling Tcl_SaveInterpState, passing in the code argument. When the asynchronous handler is finished it should restore the interpreter's state by calling Tcl_RestoreInterpState, and then returning the code argument. KEYWORDS
asynchronous event, handler, signal, Tcl_SaveInterpState, thread Tcl 7.0 Tcl_AsyncCreate(3)
All times are GMT -4. The time now is 08:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy