Sponsored Content
Top Forums Programming Pipe usage error while visiting directories Post 303032910 by Corona688 on Tuesday 26th of March 2019 02:15:21 PM
Old 03-26-2019
If you really wanted to do IPC between processes just to count directories, though, shared memory beats pipes IMO. mmap() an anonymous segment, and each fork()ed process will have access to it. Give each child a unique index to mess with so they don't stomp on each other, wait() for each child to quit, and tada.
This User Gave Thanks to Corona688 For This Post:
 

10 More Discussions You Might Find Interesting

1. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

2. AIX

broken pipe error

Hi, I am working on AIX 5.3 . I have client-server program which is in ProC.while sending packet to server i am getting error as broken pipe and program exiting. please help?/? (1 Reply)
Discussion started by: ajaysahoo
1 Replies

3. UNIX for Dummies Questions & Answers

du - Disk Usage for only files and NOT directories.

Hello, Could any one help me how to find the Disk Usage for all the files in the running directory and the sub directories without the disk usage of the directory. I mean to say, i need only the file names without the size of the directories. See, i used this command du -a .|sort... (3 Replies)
Discussion started by: RRVARMA
3 Replies

4. AIX

How to monitor the IBM AIX server for I/O usage,memory usage,CPU usage,network..?

How to monitor the IBM AIX server for I/O usage, memory usage, CPU usage, network usage, storage usage? (3 Replies)
Discussion started by: laknar
3 Replies

5. Programming

Broken Pipe error

All, I am using the below code The C code : if ((fp2=fopen(szout_fname,"r"))==NULL) { sprintf(stream_ptr1,"cat %s | sort -t, -rn -k 11,11 | awk -F\",\" '{ \ if ( \$3 ==\"%s\" ) {print... (0 Replies)
Discussion started by: arunkumar_mca
0 Replies

6. Programming

Pipe error

hi guys, o have a big error in this program but i cant solve someone ?! #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <string.h> int main(int argc, char *argv){ int cont = 2, posicao; char geraArquivo= "|cat>>", espaco=" "; char nomeArquivo, comando,... (11 Replies)
Discussion started by: beandj
11 Replies

7. Shell Programming and Scripting

Broken Pipe error

Hello while doing sftp over server "A" , i am getting a broken pipe error i.e cat: write error: Broken pipe what does that mean? please let me know if you want any other info on this.. (3 Replies)
Discussion started by: urfrnddpk
3 Replies

8. Shell Programming and Scripting

listing file date and time without usage of pipe

Hi , I am using below code to list the 6th,7th and 8th field of the file ls -lrt test | awk '{print $6,$7,$8}' output: Nov 21 19:34 Now the problem here is that I want to do it without the usage of pipes as its now allowed in my production environment Please let me know... (6 Replies)
Discussion started by: harish612
6 Replies

9. UNIX for Dummies Questions & Answers

broken pipe error

I'm new to scripting, and this forum has been invaluable in helping me out. I'm hoping I can get some personal help now though. I have a korn script that takes a list of servers and either telnets or sshs into it (only some are set up for ssh). What I'm doing now is trying to telnet first, and... (10 Replies)
Discussion started by: aimeet
10 Replies

10. Shell Programming and Scripting

Capture error before pipe

Hi, I have a script that runs a tar command to standard out then pipes to a gzip: tar cfE - * | gzip -c > OUT.gz At the moment, even if the tar fails (e.g. because of lack of disk space), the gzip still runs successfully. Is there a way to make the whole line exit with a non-zero error... (6 Replies)
Discussion started by: Catullus
6 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)
All times are GMT -4. The time now is 08:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy