X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Recipient: djgpp AT delorie DOT com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=DarZ4inHrDwkNuAk+t59h4d8NLtptTNm/gW4WQqvmos=; b=okLLRuSIHE66iWOv0bd26EwwgChMupjUSj8NMYXoXHF7lD5Q71cNgLtiATKP4F7r/g Nc+rxhYPcbqjfpgjuNiJ/58t/SW2rxTtCF+zwMigtdFTvqXf/bSWnvtVbeCwinQOujyC NXYXJkNY3ksFmp034bKEOmBkq1OSt6Cx4A5+NYdLHIrSm+vti5kolRzoNHfXQcOcp0XL dP4cwbvO9GB1qeTNhXSvA1pHaPIL3+mdGko8N7Lvv+gdqGC0yOrcTjETNIpYBY/VPW+b H9qSFnxLAdY9s1cUVOPna48tnfACaPFAM9vPIreFQsEGlfhB4CNLs9Ap81PE8IuJo0At HZCw== MIME-Version: 1.0 X-Received: by 10.52.227.138 with SMTP id sa10mr16525303vdc.25.1399845032777; Sun, 11 May 2014 14:50:32 -0700 (PDT) In-Reply-To: References: Date: Sun, 11 May 2014 17:50:32 -0400 Message-ID: Subject: Re: detecting child processes? From: Matthew Petricone To: djgpp AT delorie DOT com Content-Type: multipart/alternative; boundary=089e0111d816eb5db604f926d1b9 Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk --089e0111d816eb5db604f926d1b9 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I would consider using a temp file with some data regarding the situation, almost like a semaphore. You would have to be careful about error situations with file io. Matthew Petricone Strstream AT gmail DOT com Matt AT petricone DOT org On May 11, 2014 3:30 PM, "Hans-Bernhard Br=C3=B6ker" wrote: > On 11.05.2014 19:59, Rod Pemberton wrote: > > I have a process which spawns a child of itself via system(). >> >> Although the parent and child are the same application, I'd now >> like the child to function slightly differently from the parent. >> > > I'll assume you're referring only to the case where the parent process is > this same program, rather than your program being invoked as any arbitrar= y > other program's child process. > > To do that, I need to be able to detect that the child is not >> the parent. >> > > So make the parent _tell_ the child: set an environment variable like > "PAPA_ALREADY_THERE", pass a command line argument to the child, or > whatever you like. > --089e0111d816eb5db604f926d1b9 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

I would consider using a temp file with some data regarding = the situation, almost like a semaphore. You would have to be careful about = error situations with file io.

Matthew Petricone
Strstream AT gmail DOT com
Matt AT petricone DOT org

On May 11, 2014 3:30 PM, "Hans-Bernhard Br= =C3=B6ker" <HBBroeker AT t-on= line.de> wrote:
On 11.05.2014 19:59, Rod Pemberton wrote:

I have a process which spawns a child of itself via system().

Although the parent and child are the same application, I'd now
like the child to function slightly differently from the parent.

I'll assume you're referring only to the case where the parent proc= ess is this same program, rather than your program being invoked as any arb= itrary other program's child process.

To do that, I need to be able to detect that the child is not
the parent.

So make the parent _tell_ the child: set an environment variable like "= ;PAPA_ALREADY_THERE", pass a command line argument to the child, or wh= atever you like.
--089e0111d816eb5db604f926d1b9--