Sponsored Content
Top Forums Programming forks, ipc, fifos, update issues... Post 84822 by Funktar on Wednesday 28th of September 2005 10:44:23 PM
Old 09-28-2005
forks, ipc, fifos, update issues...

Hi, so I've got this program("main") that fork executes another ("user"). These programs communicate through fifos.

One communication is a spawn call, where user passes an executable, main forks and executes it. So, I'm keeping track of all my processes using a task table. After the fork (for the spawn call), the new child adds itself to the task table and then waits for the "user" to finish before executing. So, the user finishes what it needs, calls the end method on "main", which checks to see if there's a waiting process. It turns out when I show() my task table, the new child that I added isn't there! I can't figure out why at all. Any ideas?

Here's the 2nd child when it gets created.

Code:
pid = Fork(); 
if(pid == 0) { 
      //blah blah 
      tbl -> set(spawn_tid_c, spawn_pid_c); 
      tbl -> show(); 
      //wait 
}

Here's the output.

+ main + forking
+ TaskTbl + set(01, 19976) method called
+ TaskTbl + (01, 19976) added
<TaskTbl> has 2 items
0: <00,19975>
1: <01,19976>
+ main + waiting for system call message
+ user1 + calling s_end()
+ main + syscall task end received
<TaskTbl> has 1 items
0: <00,19975>

the end function is called immediately after the spawn function finishes, and I've checked everywhere to find something that would remove the task but the only way to do so would be for me to intentionally remove it ( remove -> (task, proc)), which I'm not doing.

I have no idea why the table is only showing 1 item immediately after. Help would be greatly appreciated.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

forks....HELP!!! someone anyone?

Hey guys, I'm given this bit of code, but, I'm having some problems executing it with the functions I've defined so far. I'm suppose to define the funtions "parse" and "execute." Parse splits the command in buf into individual arguments. It strips whitespace, replacing those it finds with NULLS... (3 Replies)
Discussion started by: richardspence2
3 Replies

2. Programming

Praying for help: FIFOs, IPC

omg i need help so bad. I've been working on a school project for what seems like an eternity and i'm close to deadline. Using FIFO's (i ahve to) to communicate between parent and child proc's. Right now I'm stuck on a read/write. fifomsg is a struct with int length and char message fields. ... (5 Replies)
Discussion started by: Funktar
5 Replies

3. Linux

A little help understanding FIFOs?

This isn't strictly a Linux question, but... I've been working on a project to archive some streaming media for time shifting using 'mplayer' and have been using FIFOs to archive in Ogg Vorbis format: mkfifo program_name.wav (mplayer -ao pcm -aofile program_name.wav &)... (0 Replies)
Discussion started by: deckard
0 Replies

4. UNIX for Advanced & Expert Users

tar and fifos

How can I make tar read data from a fifo, instead of storing it as a fifo? (8 Replies)
Discussion started by: Corona688
8 Replies

5. UNIX for Advanced & Expert Users

Question on forks and pipes

I am trying to figure out why when i have the following code int main( { printf("0\n"); fork(); printf("1\n"); exit(0);} and type in the shell a.out | cat the output of this program is 0 1 0 1 instead of 0 1 1 does anyone know? (3 Replies)
Discussion started by: Phantom12345
3 Replies

6. Programming

read from file using forks

i'm tring to make 2 processes each read from the same file but only one of them read the file. FILE * fileptr1; fileptr1 = fopen("file1.txt","rt"); pid2=fork(); while(1) { fscanf(fileptr1,"%s",temp1); if(feof(fileptr1)==0) { printf("%i",getpid()); //id of current process ... (6 Replies)
Discussion started by: ddx08
6 Replies

7. UNIX for Advanced & Expert Users

UNIX domain sockets vs FIFOs

Is there a performance advantage of one of these over the other? Obviously, it makes no sense to use normal TCP sockets or UDP sockets w/ the overhead they carry. But what about UNIX domain sockets vs FIFOs? I'd think they'd be very similar, in terms of performance and in terms of how they're... (2 Replies)
Discussion started by: mgessner
2 Replies

8. Solaris

errors on Netra-440: "IPC Warning: ipc: tcp_protocol: bad magic number"

I was asked to look into a problem with a Sun Netra 440 in another department. On the server in question, the relevant 'uname -a' information is, "SunOS host1 5.9 Generic_118558-16 sun4u sparc SUNW,Netra-440". That information aside, while the other admin is logged into the ALOM, these errors are... (0 Replies)
Discussion started by: Borealis
0 Replies

9. Programming

kill() function problem in client-server ipc message using 2 FIFOs

I want to have a message send & receive through 2 uni-direction FIFO Flow of data FIFO1 stdin--->parent(client) writefd--->FIFO1-->child(server) readfd FIFO2 child(server) writefd2---->FIFO2--->parent(client) readfd2--->stdout I need to have boundary structed message... (3 Replies)
Discussion started by: ouou
3 Replies

10. Red Hat

Issues after update

Hi guys, thanks for your kind assistance. I have a rhel6.4 server. After I did an update, the server does not reboot. Also user logins take for ever. Please any help on this matter will be appreciated . Thank you (2 Replies)
Discussion started by: cjashu
2 Replies
vfork(2)							System Calls Manual							  vfork(2)

Name
       vfork - spawn new process in a virtual memory-efficient way

Syntax
       pid = vfork()
       int pid;

Description
       The  can  be used to create new processes without fully copying the address space of the old process, which is inefficient in a paged envi-
       ronment.  It is useful when the purpose of would have been to create a new system context for an The system call differs from in  that  the
       child borrows the parent's memory and thread of control until a call to or an exit (either by a call to or abnormally.)	The parent process
       is suspended while the child is using its resources.

       The system call returns a value of zero (0) in the child's context and, later, the pid of the child in the parent's context.

       The system call can normally be used just like It does not work, however, to return while running in the childs context from the  procedure
       which  called because the eventual return from would then return to a nonexistent stack frame.  Be careful, also, to call _exit rather than
       exit if you cannot call because exit will flush and close standard I/O channels and thereby cause problems in the parent process's standard
       I/O data structures.  Even with it is wrong to call exit, because buffered data would then be flushed twice.

Restrictions
       To avoid a possible deadlock situation, processes which are children in the middle of a are never sent SIGTTOU or SIGTTIN signals.  Rather,
       output or ioctls are allowed, and input attempts result in an end-of-file indication.

Diagnostics
       Same as for

See Also
       execve(2), fork(2), sigvec(2), wait(2)

																	  vfork(2)
All times are GMT -4. The time now is 10:48 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy