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
FORK(2) 						      BSD System Calls Manual							   FORK(2)

NAME
fork -- create a new process SYNOPSIS
#include <unistd.h> pid_t fork(void); DESCRIPTION
fork() causes creation of a new process. The new process (child process) is an exact copy of the calling process (parent process) except for the following: o The child process has a unique process ID. o The child process has a different parent process ID (i.e., the process ID of the parent process). o The child process has its own copy of the parent's descriptors. These descriptors reference the same underlying objects, so that, for instance, file pointers in file objects are shared between the child and the parent, so that an lseek(2) on a descriptor in the child process can affect a subsequent read or write by the parent. This descriptor copying is also used by the shell to establish standard input and output for newly created processes as well as to set up pipes. o The child processes resource utilizations are set to 0; see setrlimit(2). RETURN VALUES
Upon successful completion, fork() returns a value of 0 to the child process and returns the process ID of the child process to the parent process. Otherwise, a value of -1 is returned to the parent process, no child process is created, and the global variable errno is set to indicate the error. ERRORS
fork() will fail and no child process will be created if: [EAGAIN] The system-imposed limit on the total number of processes under execution would be exceeded. This limit is configuration- dependent. [EAGAIN] The system-imposed limit MAXUPRC (<sys/param.h>) on the total number of processes under execution by a single user would be exceeded. [ENOMEM] There is insufficient swap space for the new process. LEGACY SYNOPSIS
#include <sys/types.h> #include <unistd.h> The include file <sys/types.h> is necessary. SEE ALSO
execve(2), sigaction(2), wait(2), compat(5) HISTORY
A fork() function call appeared in Version 6 AT&T UNIX. CAVEATS
There are limits to what you can do in the child process. To be totally safe you should restrict yourself to only executing async-signal safe operations until such time as one of the exec functions is called. All APIs, including global data symbols, in any framework or library should be assumed to be unsafe after a fork() unless explicitly documented to be safe or async-signal safe. If you need to use these frame- works in the child process, you must exec. In this situation it is reasonable to exec yourself. 4th Berkeley Distribution June 4, 1993 4th Berkeley Distribution
All times are GMT -4. The time now is 06:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy