delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/01/17/04:11:41

Xref: news-dnh.mv.net comp.os.msdos.djgpp:4470
From: nelson AT cs DOT uwp DOT edu (Jeremy Nelson)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: (none)
Date: 15 Jan 1996 21:07:14 GMT
Organization: University of Wisconsin - Parkside
Lines: 32
Message-ID: <4defm2$l2e@news.inc.net>
References: <Pine DOT SOL DOT 3 DOT 91 DOT 960113132312 DOT 12809A-100000 AT gollum>
NNTP-Posting-Host: cs.uwp.edu
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Orlando Andico  <oandico AT gollum DOT eee DOT upd DOT edu DOT ph> wrote:
>Does anyone know why gcc on multitasking systems doesn't have spawn...()? 
>(sorry if this isn't related directly to DJGPP...) I use spawn with DJGPP 
>all the time... now I want to do the same thing under Linux. But there's 
>no spawn. 

The ANSI standard (i think) defines a library call system() that is supposed 
to allow you a way to OS-independantly run a program such that you are 
guaranteed that the program will have finished execution before the call 
to system() returns.

Perhaps this is what you are looking for.  Any unix worth its salt has
ANSI compliant c libs by now (which of course precludes sunos 4. >;-)


>This seems to work, but the problem is, my program is inherently 
>single-threaded and needs something from the _thing_that_is_spawned_. 
>But due to the fork(), I can't know if the _thing_to_be_spawned_ has 
>done its thing yet... (unlike spawn which returns when the _thing..._ 
>has done its potty). Any ideas?

Look at the man pages for wait() and waitpid().  Waitpid() is pretty
good when you *know* the pid of the child (such as after a fork())
and its just what youre looking for.  wait() is more useful when you
dont know who your child is, but you know you have one.  More informative
versions of wait*() exist, but i wouldnt count on them being very
portable.

However, for you, i think what you want is the system() call which
handles all the details for you and gives you reasonble semantics.

jfn

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019