linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* ophan child process to take standard input
@ 2005-09-04 18:49 Karol Banczyk
  2005-09-05  5:33 ` Steve Graegert
  0 siblings, 1 reply; 4+ messages in thread
From: Karol Banczyk @ 2005-09-04 18:49 UTC (permalink / raw)
  To: linux-c-programming

Hello,
	I'm solving an exercise from my school. Not to go into details - the
task is to create a initiating process which in turn starts three new
processes  and then finishes its work. The three processes are to
communicate with pipes. There's no problem till this stage. But there's
the catch. The first of the three processes has to get its input from
the standard input and this works only as long as the parent
(initiating) process is alive. When the parent finishes the standard
input goes back to bash and the orphaned processes are adopted by the
init process having no access to stdin.

	What do you think? Is it a bug in the exercise or is there really a
(non-cosmic) way to achive the goal.


Thanx in advance

KB


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: ophan child process to take standard input
  2005-09-04 18:49 ophan child process to take standard input Karol Banczyk
@ 2005-09-05  5:33 ` Steve Graegert
  2005-09-05 17:42   ` Karol Banczyk
  0 siblings, 1 reply; 4+ messages in thread
From: Steve Graegert @ 2005-09-05  5:33 UTC (permalink / raw)
  To: Karol Banczyk; +Cc: linux-c-programming

On 9/4/05, Karol Banczyk <car-los@tlen.pl> wrote:
> Hello,
>        I'm solving an exercise from my school. Not to go into details - the
> task is to create a initiating process which in turn starts three new
> processes  and then finishes its work. The three processes are to
> communicate with pipes. There's no problem till this stage. But there's
> the catch. The first of the three processes has to get its input from
> the standard input and this works only as long as the parent
> (initiating) process is alive. When the parent finishes the standard
> input goes back to bash and the orphaned processes are adopted by the
> init process having no access to stdin.

This is what I would expect.  As long as the parent is running child
processes are attached to the process group's controlling terminal and
will be detached automatically when the parent is terminated.

Normally, the parent should wait (waitpid) for its childs to prevent
them of becoming orphans.  Are you waiting for them?

It would be easier to help if you would let us know what the exercise is.  


Regards

	\Steve

--

Steve Graegert <graegerts@gmail.com>
Software Consultancy {C/C++ && Java && .NET}
Mobile: +49 (176)  21248869
Office: +49 (9131) 7126409

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: ophan child process to take standard input
  2005-09-05  5:33 ` Steve Graegert
@ 2005-09-05 17:42   ` Karol Banczyk
  2005-09-05 18:01     ` 386 demand paged pure executable Nanakos Chrysostomos
  0 siblings, 1 reply; 4+ messages in thread
From: Karol Banczyk @ 2005-09-05 17:42 UTC (permalink / raw)
  To: linux-c-programming

Steve Graegert napisa³(a):
> On 9/4/05, Karol Banczyk <car-los@tlen.pl> wrote:
> 
>>Hello,
>>       I'm solving an exercise from my school. Not to go into details - the
>>task is to create a initiating process which in turn starts three new
>>processes  and then finishes its work. The three processes are to
>>communicate with pipes. There's no problem till this stage. But there's
>>the catch. The first of the three processes has to get its input from
>>the standard input and this works only as long as the parent
>>(initiating) process is alive. When the parent finishes the standard
>>input goes back to bash and the orphaned processes are adopted by the
>>init process having no access to stdin.
> 
> 
> This is what I would expect.  As long as the parent is running child
> processes are attached to the process group's controlling terminal and
> will be detached automatically when the parent is terminated.
> 
> Normally, the parent should wait (waitpid) for its childs to prevent
> them of becoming orphans.  Are you waiting for them?
> 
> It would be easier to help if you would let us know what the exercise is.  
> 
> 
> Regards
> 
> 	\Steve


Hello again
Thanks for reply, Steve,

So - let's describe the whole exercise. I've done almost everything 
except the "finish parent" part.

We have to: create an initializing process that would create 3 processes:
1. first one to read from stdin and send read lines to a named pipe,
2. second to read from the pipe from proc 1, display the lines and to 
write the to another pipe numbers of characters from the read lines,
3. third one to read from the pipe form proc 2 and to display the numbers.

No there is a restriction that the initializing process should just 
"init the processes and finish immediately". The rest of the task is 
about using signals to suspend/continue the pipe communication or the 
finish all the processes. It's rather unimportant for my problem apart 
from the fact, that the three processes have to communicate with each 
other using signal (which makes it even harder if you really have to 
kill the parent process).


My solution fulfills all the requirements of the exercise except for the 
termination of the initilizing process. As you said, Steve, I do wait 
for all the three child processes in parent - interpreting the exercise 
to my convenience that "fihishing" is a way of "being suspended" or 
"doing nothing".

I just don't know if the creator of the task wants me to do some 
extraordinary magic with process groups and task controlling processes 
or is it just a bug. I can't find a way to give an orphan process access 
to a terminal which has no realtion with it (after a orphaned process is 
adopted by init). Is it anyway a good programming style to create 
orphaned processes??

Or maybe there is a way to create process that are not child processes? 
I currently create child processes using the fork function..

I hope my description has enough details now. Thanks


KB

-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* 386 demand paged pure executable
  2005-09-05 17:42   ` Karol Banczyk
@ 2005-09-05 18:01     ` Nanakos Chrysostomos
  0 siblings, 0 replies; 4+ messages in thread
From: Nanakos Chrysostomos @ 2005-09-05 18:01 UTC (permalink / raw)
  To: linux-c-programming

Hi, how can i produce in a working RH 9 env a 386 - demand pages pure
executable from a C file???


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-09-05 18:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-04 18:49 ophan child process to take standard input Karol Banczyk
2005-09-05  5:33 ` Steve Graegert
2005-09-05 17:42   ` Karol Banczyk
2005-09-05 18:01     ` 386 demand paged pure executable Nanakos Chrysostomos

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).