11-21-2010
Well, it sounds like you need a protocol, or operate your pipes full duplex with at state machine at each end to take care of activities on that overlaid protocol. Decoding & analyzing professors is much more complex than decoding & analyzing an API.
If you find pipes, sockets, shmem, semaphores, queues and all that a bit restrictive, you can mmap() a file in both processes, creating an area of shared memory, not to be confused with the silly UNIX ipc shared memory that needs root setup and such dusty old stuff, and the nice thing is that you can peek at the mmap90'd file during or after for you edification about what is going on. It is really fast, RAM write snoop invalidating cache fast. You can even have a file for each writer, so there is no ambiguity about who put the file in that state.
10 More Discussions You Might Find Interesting
1. Programming
Hi everybody,
I'm trying to understand how a parent and child processes interact.
This function( below) basically measures the fork time from the perspective of the parent only.
what i would like to know is how to measure the time from the perspective of parent and child (ie: inserting... (0 Replies)
Discussion started by: tosa
0 Replies
2. Programming
Hi all,
I'm trying to write a program that has some data it wants to send through a filter program(in this case tr), and then recieve the output from that filter program. The way I'm trying to do it is by setting up two pipes between the programs and piping the data in through one pipe and back... (2 Replies)
Discussion started by: bwgoudey
2 Replies
3. UNIX for Advanced & Expert Users
Hi
I am trying to see if there are some options in ps command or if there is a shell script which basically shows you all the processes spawned by a parent process , then all the processes of its child processes and so on down the hierarchy may be like a tree structure. It might be a generic... (6 Replies)
Discussion started by: clifford
6 Replies
4. 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
5. UNIX for Dummies Questions & Answers
Hi All,
I facing a problem in handling signals between parent process communication. I am trying to send a signal(SIGINT) from child to parent. I am using kill function to do so and I am trying to read the signal using sigaction(). But the program is ending abruptly and I am not able to figure out... (4 Replies)
Discussion started by: vkn_1985
4 Replies
6. 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
7. 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
8. 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
9. IP Networking
Hi,
I am trying my hand in networking programming in C, and got stuck in piping.
I was following some tutorial and did the forking like :
while (1)
{
newsockfd = accept(sockfd,
(struct sockaddr *) &cli_addr, &clilen);
if (newsockfd < 0)
... (4 Replies)
Discussion started by: abhi1988sri
4 Replies
10. Shell Programming and Scripting
Hi all,
I am starting mgen5 for sometime depends on input from a file, in a child process. now I want to make parent to wait in this child process till mgen5 finishes, or timeout happens.
could anyone please tell me how to make parent to wait in child process in shell script?
thanks... (2 Replies)
Discussion started by: girijajoshi
2 Replies
Child(3pm) User Contributed Perl Documentation Child(3pm)
NAME
Child - Object oriented simple interface to fork()
DESCRIPTION
Fork is too low level, and difficult to manage. Often people forget to exit at the end, reap their children, and check exit status. The
problem is the low level functions provided to do these things. Throw in pipes for IPC and you just have a pile of things nobody wants to
think about.
Child is an Object Oriented interface to fork. It provides a clean way to start a child process, and manage it afterwords. It provides
methods for running, waiting, killing, checking, and even communicating with a child process.
NOTE: kill() is unpredictable on windows, strawberry perl sends the kill signal to the parent as well as the child.
SYNOPSIS
BASIC
use Child;
my $child = Child->new(sub {
my ( $parent ) = @_;
....
# exit() is called for you at the end.
});
my $proc = $child->start
# Kill the child if it is not done
$proc->complete || $proc->kill(9);
$proc->wait; #blocking
IPC
# Build with IPC
my $child2 = Child->new(sub {
my $self = shift;
$self->say("message1");
$self->say("message2");
my $reply = $self->read(1);
}, pipe => 1 );
my $proc2 = $child2->start;
# Read (blocking)
my $message1 = $proc2->read();
my $message2 = $proc2->read();
$proc2->say("reply");
SHORTCUT
Child can export the child() shortcut function when requested. This function creates and starts the child process in one action.
use Child qw/child/;
my $proc = child {
my $parent = shift;
...
};
You can also request IPC:
use Child qw/child/;
my $child = child {
my $parent = shift;
...
} pipe => 1;
DETAILS
First you define a child, you do this by constructing a Child object. Defining a child does not start a new process, it is just the way to
define what the new process will look like. Once you have defined the child you can start the process by calling $child->start(). One child
object can start as many processes as you like.
When you start a child an Child::Link::Proc object is returned. This object provides multiple useful methods for interacting with your
process. Within the process itself an Child::Link::Parent is created and passed as the only parameter to the function used to define the
child. The parent object is how the child interacts with its parent.
PROCESS MANAGEMENT METHODS
@procs = Child->all_procs()
Get a list of all the processes that have been started. This list is cleared in processes when they are started; that is a child will
not list its siblings.
@pids = Child->all_proc_pids()
Get a list of all the pids of processes that have been started.
Child->wait_all()
Call wait() on all processes.
EXPORTS
$proc = child( sub { ... } )
$proc = child { ... }
$proc = child( sub { ... }, $plugin, @data )
$proc = child { ... } $plugin => @data
Create and start a process in one action.
CONSTRUCTOR
$child = Child->new( sub { ... } )
$child = Child->new( sub { ... }, $plugin, @plugin_data )
Create a new Child object. Does not start the child.
OBJECT METHODS
$proc = $child->start()
Start the child process.
SEE ALSO
Child::Link::Proc
The proc object that is returned by $child->start()
Child::Link::Parent
The parent object that is provided as the argumunt to the function used to define the child.
Child::Link::IPC
The base class for IPC plugin link objects. This provides the IPC methods.
HISTORY
Most of this was part of Parrallel::Runner intended for use in the Fennec project. Fennec is being broken into multiple parts, this is one
such part.
FENNEC PROJECT
This module is part of the Fennec project. See Fennec for more details. Fennec is a project to develop an extendable and powerful testing
framework. Together the tools that make up the Fennec framework provide a potent testing environment.
The tools provided by Fennec are also useful on their own. Sometimes a tool created for Fennec is useful outside the greator framework.
Such tools are turned into their own projects. This is one such project.
Fennec - The core framework
The primary Fennec project that ties them all together.
AUTHORS
Chad Granum exodist7@gmail.com
COPYRIGHT
Copyright (C) 2010 Chad Granum
Child is free software; Standard perl licence.
Child is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
perl v5.10.1 2011-03-07 Child(3pm)