From owner-freebsd-questions Sun Jul 8 4:40:54 2001 Delivered-To: freebsd-questions@freebsd.org Received: from imf11bis.bellsouth.net (mail311.mail.bellsouth.net [205.152.58.171]) by hub.freebsd.org (Postfix) with ESMTP id 4D6E837B403 for ; Sun, 8 Jul 2001 04:40:44 -0700 (PDT) (envelope-from leimbacd@bellsouth.net) Received: from mutt.home.net ([208.63.161.96]) by imf11bis.bellsouth.net (InterMail vM.5.01.01.01 201-252-104) with ESMTP id <20010708114135.RKGY24466.imf11bis.bellsouth.net@mutt.home.net> for ; Sun, 8 Jul 2001 07:41:35 -0400 Received: (from dave@localhost) by mutt.home.net (8.11.3/8.11.3) id f68BiiF00605 for questions@freebsd.org; Sun, 8 Jul 2001 06:44:44 -0500 (CDT) (envelope-from dave) Date: Sun, 8 Jul 2001 06:44:44 -0500 From: David Leimbach To: questions@freebsd.org Subject: Re: Passing data in C++ via stdin without waiting for the new process to complete Message-ID: <20010708064444.A519@mutt.home.net> References: <114577608557.20010708130014@buz.ch> <3B484403.1BA9A21D@jak.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable User-Agent: Mutt/1.2.5i In-Reply-To: <3B484403.1BA9A21D@jak.nl>; from arjan@jak.nl on Sun, Jul 08, 2001 at 01:29:07PM +0200 X-Operating-System: FreeBSD mutt.home.net 4.3-RELEASE FreeBSD 4.3-RELEASE Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG also all the different versions of exec: man: execl, execlp, execle, exect, execv, execvp=20 Fork makes a copy of the current process. If you want to run something else after a fork do an exec. system does a fork, exec and wait. you seem to want everything but the wait. :) Dave On Sun, Jul 08, 2001 at 01:29:07PM +0200, Arjan Knepper wrote: > read : >=20 > man -a 2 fork > man -a 2 rfork > man -a 2 vfork > man -a 2 wait > man -a 2 _exit > man -a 3 exit > man -a 2 dup dup2 >=20 > Good luck > Arjan Knepper >=20 > P.S Buy the book : "Advanced Programming in teh UNIX environment" by > W.R.Stevens ISBN:0-201-56317-7 and maybe his other books about "Unix > Network Programming" as well. > (Saw those for sale on the streets in NY !!) >=20 > Gabriel Ambuehl wrote: >=20 > > -----BEGIN PGP SIGNED MESSAGE----- > > > > Hello, > > > > I wonder how I could efficiently achieve to pass data via stdin to a > > new process spawned by the current one without having the parent > > process waiting for the child to complete. I just want to spawn the > > child, pass the data to it and then forget about it, no matter how > > long it takes for the child to complete. > > > > popen() doesn't appear to be a suitable tool for this kind of work as > > the manpage says: > > > > The pclose() function waits for the associated process to > > terminate and > > returns the exit status of the command as returned by wait4(). > > > > which means that the parent is blocked til the client finishes. > > > > system("echo data | some_app"); > > does work, but the parent process still is blocked till the child > > finishes and I don't think it's the most efficient of all ideas to > > first spawn a shell (although popen() appears to be doing this as > > well), then spawn an instance of echo just to get the data where it > > should be and then spawn the third process to do the actual work. > > > > Any comments would greatly be appreciated. > > > > TIA & best regards, > > Gabriel > > =04 > > > > -----BEGIN PGP SIGNATURE----- > > Version: PGP 6.5i > > > > iQEVAwUBO0gvNMZa2WpymlDxAQGQ2QgAu3XWwCawKeL8UcozL15BthwMIN3Ousow > > mL3AQpQUDrV3areksXaQLnGwjTVUZMZf+wSruYKXubwcl3uTI5RmH38QvoDrD9OU > > 045BJhSsu0AxsX8oNGTm/Ch9vr9onJzJF3Ur5AdzwG2FQJ8pH2HkFF3sBJw1HklY > > p7+WpJgBIF3g4aFyTKoAe/qJihsBgIiPDoWbXRG8lISf84YBcmUOecE0NAHjPMjB > > OjF3O+YFKys+JLHBrVwMGnNxKPzEmMFLZrZbdaW0PFpQMXEn+oxaTHfgDMhCdIyo > > BcH0nAxBnXZRX2jzXExs/ITVNsOatuaFRN6XT2QR9tt304dqKm/tLw=3D=3D > > =3DqE6e > > -----END PGP SIGNATURE----- > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > > with "unsubscribe freebsd-questions" in the body of the message >=20 >=20 > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-questions" in the body of the message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message