Sponsored Content
Top Forums Programming Newbie question on exec,fork, wait,pipe C Post 302527708 by Cuervo on Saturday 4th of June 2011 06:27:43 PM
Old 06-04-2011
Newbie question on exec,fork, wait,pipe C

Hello everybody.I want to make clear that i am not going to ask from anybody to build my asignement but i have a big problem. I can't seem to find anywhere ONE good example on C about what i am trying to doSmilie.I think it is simple. All i ask is one example, even a link is fine.
So, i want to make a program (Grandfather.c) which will run 2 new existing programs (Father.c,Son.c). Father.c needs to make some calculations.He wakes up Son.c.He sends him two numbers and Son.c adds them and sends back the result.After this Son.c sleeps.
So,to sum up:
1.Grandfother.c runs the 2 programs
2.Son.c builds the pipes and falls asleep
3.Father.c wakes his son and sends him 2 numbers and falls asleep
4.Son.c adds the numbers, sends them back and falls asleep again

I have found several examples that use functions in one program,but i don't understand how to establish connection in 3 programs.Thnak you in advance!!

Last edited by Cuervo; 06-04-2011 at 09:10 PM..
 

10 More Discussions You Might Find Interesting

1. Programming

Fork and exec

Hello! I am working on a server where I should have 4 (resident)processes, one of them being "the father" of the others, so I do 3 forks. The problem that I have is that I do an accept (for sockets) in the "father" process and I want to transmit the job to one of the processes "child" with... (3 Replies)
Discussion started by: driki
3 Replies

2. UNIX for Dummies Questions & Answers

FORK/EXEC technique

Hi! Can someone explain me exactly this technique? Why a process (PARENT) creates a copy of itself with FORK (CHILD)? What's the reason of this behaviour? Sorry, but I cannot understand the logic behind it. Thanks. (4 Replies)
Discussion started by: marshmallow
4 Replies

3. Solaris

fork and exec ftp

Hi, I need to find/implement an application that FTPs (puts) all new files in a certain directory to an external storage unit. This application should check for new files every 10 seconds (leaving the FTP connection open in between the 10 seconds). The easiest way would be if there are... (2 Replies)
Discussion started by: KittyJ
2 Replies

4. Shell Programming and Scripting

fork and exec

I need to ssh to a remote server and run my script there. This is my script. $ssh = "ssh username@host"; $cmd = "$ssh 'cd <my dir> && < sudo Run_exe>'"; my $pid = fork; if ($pid == 0){ exec $cmd; } When I run this I get: pccons_getchar: got r == 0 (1 Reply)
Discussion started by: looza
1 Replies

5. Red Hat

Fork wait in background process - large delay

hi all, We are trying to run a process in the background and in the process we call fork ;and wait for the child process to finish .We find that the died = wait(&status); happens after 10 seconds randomly and sometimes completes in time (within 1 sec) This behavior is seen only when the... (0 Replies)
Discussion started by: vishnu.priya
0 Replies

6. Red Hat

Fork wait in background process - large delay

hi all, We are trying to run a process in the background and in the process we call fork ;and wait for the child process to finish .We find that the died = wait(&status); happens after 10 seconds randomly and sometimes completes in time (within 1 sec) This behavior is seen only when the... (1 Reply)
Discussion started by: vishnu.priya
1 Replies

7. Shell Programming and Scripting

Newbie question-do I pause and exec my shell scripts?

Hi there, I'm writing a script to restore 3 directories and 3 mysql db's every 24 hours. While writing the script, I came across the thought... Do I need to pause between executions? Example: msql restore1.sql rm -Rf path1/* cp -Rf path1/* /restore1 chmod 777 /folder1/cache1 ... (2 Replies)
Discussion started by: semiotics101
2 Replies

8. UNIX for Dummies Questions & Answers

fork with exec

What is is difference between 'fork with exec' and 'fork without exec'? How both are related? (1 Reply)
Discussion started by: kkalyan
1 Replies

9. Programming

Linux fork, execv, wait question

Hi All, I have a program for class that needs to do the following: 1. Print the directory entries from the current directory using ncurses 2. Provide a prompt next to each directory entry and allow the user to enter commands that may or may not be about the file 3. Execute those commands in... (1 Reply)
Discussion started by: afulldevnull
1 Replies

10. UNIX for Beginners Questions & Answers

Question about global environment variables & fork() exec()

Hello... And thanks in advance for any help anyone can offer me on my question! I've been doing a lot of reading to try and find my answer... But I haven't had any luck What I'm trying to understand is where a child process inherits global environment variables from? I understand the exec()... (2 Replies)
Discussion started by: bodisha
2 Replies
ENCHANT_DICT_QUICK_CHECK(3)						 1					       ENCHANT_DICT_QUICK_CHECK(3)

enchant_dict_quick_check - Check the word is correctly spelled and provide suggestions

SYNOPSIS
bool enchant_dict_quick_check (resource $dict, string $word, [array &$suggestions]) DESCRIPTION
If the word is correctly spelled return TRUE, otherwise return FALSE, if suggestions variable is provided, fill it with spelling alterna- tives. PARAMETERS
o $dict - Dictionary resource o $word - The word to check o $suggestions - If the word is not correctly spelled, this variable will contain an array of suggestions. RETURN VALUES
Returns TRUE if the word is correctly spelled or FALSE EXAMPLES
Example #1 A enchant_dict_quick_check(3) example <?php $tag = 'en_US'; $r = enchant_broker_init(); if (enchant_broker_dict_exists($r,$tag)) { $d = enchant_broker_request_dict($r, $tag); enchant_dict_quick_check($d, 'soong', $suggs); print_r($suggs); } ?> The above example will output something similar to: Array ( [0] => song [1] => snog [2] => soon [3] => Sang [4] => Sung [5] => sang [6] => sung [7] => sponge [8] => spongy [9] => snag [10] => snug [11] => sonic [12] => sing [13] => songs [14] => Son [15] => Sonja [16] => Synge [17] => son [18] => Sejong [19] => sarong [20] => sooner [21] => Sony [22] => sown [23] => scone [24] => song's ) SEE ALSO
enchant_dict_check(3), enchant_dict_suggest(3). PHP Documentation Group ENCHANT_DICT_QUICK_CHECK(3)
All times are GMT -4. The time now is 01:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy