Sponsored Content
Full Discussion: Parent,child wait,signal
Top Forums Programming Parent,child wait,signal Post 302528255 by Corona688 on Monday 6th of June 2011 06:51:06 PM
Old 06-06-2011
there's a reason I was using stderr, printf() is buffered. That printf(), without a newline, doesn't print until your program quits! Especially weird things can happen to printf statements in a fork, too -- if you have text waiting in a buffer like that, it will be printed twice. Try printing to stderr. It prints immediately with no buffer.

Also, try writing hid\n instead of hid. I think fifos and pipes may line-buffer.

Last edited by Corona688; 06-06-2011 at 08:01 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

how to make a parent wait on a child shells running in background?

Hi I have a shell script A which calls another 10 shell scripts which run in background. How do i make the parent script wait for the child scripts complete, or in other words, i must be able to do a grep of parent script to find out if the child scripts are still running. My Code: ... (1 Reply)
Discussion started by: albertashish
1 Replies

2. Programming

How can I make the parent thread wait

Hi All, I will be glad if you could help me resolve this problem. I have created two detachable threads and wanted to them execute independent of the parent thread ( the main task which creates the detachable threads). But I see no output coming from the execution of two detachable threads.... (4 Replies)
Discussion started by: jayfriend
4 Replies

3. Shell Programming and Scripting

How to make the parent process to wait for the child process

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

4. UNIX for Dummies Questions & Answers

Sending signal from child to parent process!

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

5. Programming

Parent process starts before the child using signal, in C

Hi, i want that the parent process start before the child, this code doesn't work, if the child start before the parent it wait for signal, then the father send the signal SIGALRM and the child catch it and call printf; else the father call printf and send the signal to the child that call its... (1 Reply)
Discussion started by: blob84
1 Replies

6. Homework & Coursework Questions

Need help with deleting childīs parent and child subprocess

1. The problem statement, all variables and given/known data: I need to make an program that in a loop creates one parent and five children with fork(). The problem i'm trying to solve is how to delete the parent and child of the childīs process. 2. Relevant commands, code, scripts,... (0 Replies)
Discussion started by: WhiteFace
0 Replies

7. Emergency UNIX and Linux Support

signal between parent process and child process

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

forking a child process and kill its parent to show that child process has init() as its parent

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. Shell Programming and Scripting

parent process needs to wait

I have two scripts lets say A.expect and B.sh needs to be executed. I am executing B.sh from A.expect where B.sh has sleep command. My problem is that when B.sh encounters the sleep command my A.expect starts executing and exits. but my A.expect should execute only after completing B.sh. Is... (3 Replies)
Discussion started by: priya@2012
3 Replies

10. Shell Programming and Scripting

How make parent to wait from child process?

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
SETBUF(3S)																SETBUF(3S)

NAME
setbuf, setbuffer, setlinebuf - assign buffering to a stream SYNOPSIS
#include <stdio.h> setbuf(stream, buf) FILE *stream; char *buf; setbuffer(stream, buf, size) FILE *stream; char *buf; int size; setlinebuf(stream) FILE *stream; DESCRIPTION
The three types of buffering available are unbuffered, block buffered, and line buffered. When an output stream is unbuffered, information appears on the destination file or terminal as soon as written; when it is block buffered many characters are saved up and written as a block; when it is line buffered characters are saved up until a newline is encountered or input is read from stdin. Fflush (see fclose(3S)) may be used to force the block out early. Normally all files are block buffered. A buffer is obtained from malloc(3) upon the first getc or putc(3S) on the file. If the standard stream stdout refers to a terminal it is line buffered. The standard stream stderr is always unbuffered. Setbuf is used after a stream has been opened but before it is read or written. The character array buf is used instead of an automati- cally allocated buffer. If buf is the constant pointer NULL, input/output will be completely unbuffered. A manifest constant BUFSIZ tells how big an array is needed: char buf[BUFSIZ]; Setbuffer, an alternate form of setbuf, is used after a stream has been opened but before it is read or written. The character array buf whose size is determined by the size argument is used instead of an automatically allocated buffer. If buf is the constant pointer NULL, input/output will be completely unbuffered. Setlinebuf is used to change stdout or stderr from block buffered or unbuffered to line buffered. Unlike setbuf and setbuffer it can be used at any time that the file descriptor is active. A file can be changed from unbuffered or line buffered to block buffered by using freopen (see fopen(3S)). A file can be changed from block buffered or line buffered to unbuffered by using freopen followed by setbuf with a buffer argument of NULL. SEE ALSO
fopen(3S), getc(3S), putc(3S), malloc(3), fclose(3S), puts(3S), printf(3S), fread(3S) BUGS
The standard error stream should be line buffered by default. The setbuffer and setlinebuf functions are not portable to non-4.2BSD versions of UNIX. On 4.2BSD and 4.3BSD systems, setbuf always uses a suboptimal buffer size and should be avoided. Setbuffer is not usually needed as the default file I/O buffer sizes are optimal. 4th Berkeley Distribution May 12, 1986 SETBUF(3S)
All times are GMT -4. The time now is 06:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy