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

NAME
exits, _exits, atexit, atexitdont, terminate - terminate process, process cleanup SYNOPSIS
#include <u.h> #include <libc.h> void _exits(char *msg) void exits(char *msg) int atexit(void(*)(void)) void atexitdont(void(*)(void)) /* Alef only */ void _exits(byte *msg) void exits(byte *msg) void terminate(byte *msg) DESCRIPTION
Exits is the conventional way to terminate a process. _Exits is the underlying system call. They can never return. Msg conventionally includes a brief (maximum length ERRLEN) explanation of the reason for exiting, or a null pointer or empty string to indicate normal termination. The string is passed to the parent process, prefixed by the name and process id of the exiting process, when the parent does a wait(2). Before calling _exits with msg as an argument, exits calls in reverse order all the functions recorded by atexit. Atexit records fn as a function to be called by exits. It returns zero if it failed, nonzero otherwise. A typical use is to register a cleanup routine for an I/O package. To simplify programs that fork or share memory, exits only calls those atexit-registered functions that were registered by the same process as that calling exits. Calling atexit twice (or more) with the same function argument causes exits to invoke the function twice (or more). There is a limit to the number of exit functions that will be recorded; atexit returns 0 if that limit has been reached. Atexitdont cancels a previous registration of an exit function. Alef In Alef, the system call _exits is the same, but its use is discouraged because the run-time system needs to maintain consistency; termi- nate and exits are the recommended routines. Terminate is called automatically when a task or proc returns from its main function; it may also be called explicitly. In either case, it frees resources private to the task (which may be the implicit main task within the proc) and terminates that task. If that task is the last one in the proc, resources private to the proc are then freed. If that proc is the last one in the program, it calls exits. Exits should only be called in the last proc of a program; it calls any atexit functions (regis- tered by any proc) and then calls _exits. In Alef, atexit and atexitdont behave the same as in C. SOURCE
/sys/src/libc/port/atexit.c SEE ALSO
fork(2), wait(2) EXITS(2)
All times are GMT -4. The time now is 04:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy