12-24-2007
Quote:
Originally Posted by
porter
You can't use sleep to reliably synchronise between processes, you need to use events and state. In UNIX the the best two events are
(a) a process terminating yielding an exit code
(b) reading of a stream
Exactly right !
But since its a scripting problem I presented a much simpler solution to implement and use.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
If your process makes a system call, then while the system call code is being run in the kernel, is your process READY, RUNNING or BLOCKED? (1 Reply)
Discussion started by: ianlow
1 Replies
2. Shell Programming and Scripting
Hi All,
I have two ksh script. 1st script calls the 2nd script and the second script calls an 'C' program.
I want 1st script to wait until the 'C' program completes.
I cant able to get the process id for the 'C' program (child process) to make the 1st script to wait for the second... (7 Replies)
Discussion started by: sennidurai
7 Replies
3. Shell Programming and Scripting
Hey all, I need to launch a script from within 2 other scripts that can run independently of the two parent scripts... Im having a hard time doing this, if anyone knows how please let me know.
More detail.
ScriptA (bash), ScriptB (ksh), ScriptC (bash)
ScriptA, launches ScriptB
ScirptB,... (7 Replies)
Discussion started by: trey85stang
7 Replies
4. UNIX for Advanced & Expert Users
I'm using
"Linux hostname 2.6.28-15-generic #49-Ubuntu SMP Tue Aug 18 18:40:08 UTC 2009 i686 GNU/Linux"
All the client machines will use Thin-client ,I will use my laptop for working and I will
mount my home directory from server to my laptop.
If I open the firefox in my laptop the... (1 Reply)
Discussion started by: ungalnanban
1 Replies
5. Shell Programming and Scripting
!/bin/sh
pid=$(ps -Aj | grep MSTRSvr | grep -v grep | awk '{print $1}')
sid=$(ps -Aj | grep MSTRSvr | grep -v grep | awk '{print $3}')
ps -s "$sid"
I am not able to get the desired output it says process list error
if i use watch ps -s "$sid" it considers only the first session id (5 Replies)
Discussion started by: schippada
5 Replies
6. Emergency UNIX and Linux Support
Hello, everyone.
Here's a program:
pid_t pid = fork();
if (0 == pid) // child process
{
execvp ...;
}
I send a signal (such as SIGINT) to the parent process, the child process receive the signal as well as the parent process.
However I don't want to child process to receive the... (7 Replies)
Discussion started by: jackliang
7 Replies
7. Shell Programming and Scripting
Hi everyone
i am very new to linux , working on bash shell.
I am trying to solve the given problem
1. Create a process and then create children using fork
2. Check the Status of the application for successful running.
3. Kill all the process(threads) except parent and first child... (2 Replies)
Discussion started by: vizz_k
2 Replies
8. BSD
Hi Experts,
I am facing one problem here which is one process always stuck in running state which causes the other similar process to sleep state . This causes my system in hanged state.
On doing cat /proc/<pid>wchan showing the "__init_begin" in the output.
Can you please help me here... (0 Replies)
Discussion started by: naveeng
0 Replies
9. UNIX for Advanced & Expert Users
Hi Experts,
I am facing one problem here which is one process always stuck in running state which causes the other similar process to sleep state . This causes my system in hanged state.
On doing cat /proc/<pid>wchan showing the "__init_begin" in the output.
Can you please help me here... (1 Reply)
Discussion started by: naveeng
1 Replies
10. UNIX for Advanced & Expert Users
Hi Experts,
I am facing one problem here which is one process always stuck in running state which causes the other similar process to sleep state . This causes my system in hanged state.
On doing cat /proc/<pid>wchan showing the "__init_begin" in the output.
Can you please help me here... (6 Replies)
Discussion started by: naveeng
6 Replies
LEARN ABOUT REDHAT
tcl_dooneevent
Tcl_DoOneEvent(3) Tcl Library Procedures Tcl_DoOneEvent(3)
__________________________________________________________________________________________________________________________________________________
NAME
Tcl_DoOneEvent - wait for events and invoke event handlers
SYNOPSIS
#include <tcl.h>
int
Tcl_DoOneEvent(flags)
ARGUMENTS
int flags (in) This parameter is normally zero. It may be an OR-ed combination of any of the following flag bits: TCL_WIN-
DOW_EVENTS, TCL_FILE_EVENTS, TCL_TIMER_EVENTS, TCL_IDLE_EVENTS, TCL_ALL_EVENTS, or TCL_DONT_WAIT.
_________________________________________________________________
DESCRIPTION
This procedure is the entry point to Tcl's event loop; it is responsible for waiting for events and dispatching event handlers created with
procedures such as Tk_CreateEventHandler, Tcl_CreateFileHandler, Tcl_CreateTimerHandler, and Tcl_DoWhenIdle. Tcl_DoOneEvent checks to see
if events are already present on the Tcl event queue; if so, it calls the handler(s) for the first (oldest) event, removes it from the
queue, and returns. If there are no events ready to be handled, then Tcl_DoOneEvent checks for new events from all possible sources. If
any are found, it puts all of them on Tcl's event queue, calls handlers for the first event on the queue, and returns. If no events are
found, Tcl_DoOneEvent checks for Tcl_DoWhenIdle callbacks; if any are found, it invokes all of them and returns. Finally, if no events or
idle callbacks have been found, then Tcl_DoOneEvent sleeps until an event occurs; then it adds any new events to the Tcl event queue, calls
handlers for the first event, and returns. The normal return value is 1 to signify that some event was processed (see below for other
alternatives).
If the flags argument to Tcl_DoOneEvent is non-zero, it restricts the kinds of events that will be processed by Tcl_DoOneEvent. Flags may
be an OR-ed combination of any of the following bits:
TCL_WINDOW_EVENTS - Process window system events.
TCL_FILE_EVENTS - Process file events.
TCL_TIMER_EVENTS - Process timer events.
TCL_IDLE_EVENTS - Process idle callbacks.
TCL_ALL_EVENTS - Process all kinds of events: equivalent to OR-ing together all of the above flags or specifying none of them.
TCL_DONT_WAIT - Do not sleep: process only events that are ready at the time of the call.
If any of the flags TCL_WINDOW_EVENTS, TCL_FILE_EVENTS, TCL_TIMER_EVENTS, or TCL_IDLE_EVENTS is set, then the only events that will be con-
sidered are those for which flags are set. Setting none of these flags is equivalent to the value TCL_ALL_EVENTS, which causes all event
types to be processed. If an application has defined additional event sources with Tcl_CreateEventSource, then additional flag values may
also be valid, depending on those event sources.
The TCL_DONT_WAIT flag causes Tcl_DoOneEvent not to put the process to sleep: it will check for events but if none are found then it
returns immediately with a return value of 0 to indicate that no work was done. Tcl_DoOneEvent will also return 0 without doing anything
if the only alternative is to block forever (this can happen, for example, if flags is TCL_IDLE_EVENTS and there are no Tcl_DoWhenIdle
callbacks pending, or if no event handlers or timer handlers exist).
Tcl_DoOneEvent may be invoked recursively. For example, it is possible to invoke Tcl_DoOneEvent recursively from a handler called by
Tcl_DoOneEvent. This sort of operation is useful in some modal situations, such as when a notification dialog has been popped up and an
application wishes to wait for the user to click a button in the dialog before doing anything else.
KEYWORDS
callback, event, handler, idle, timer
Tcl 7.5 Tcl_DoOneEvent(3)