Return-Path: Delivered-To: apmail-apr-dev-archive@www.apache.org Received: (qmail 72355 invoked from network); 16 Apr 2007 17:31:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 Apr 2007 17:31:43 -0000 Received: (qmail 67697 invoked by uid 500); 16 Apr 2007 17:31:48 -0000 Delivered-To: apmail-apr-dev-archive@apr.apache.org Received: (qmail 67646 invoked by uid 500); 16 Apr 2007 17:31:47 -0000 Mailing-List: contact dev-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Id: Delivered-To: mailing list dev@apr.apache.org Received: (qmail 67631 invoked by uid 99); 16 Apr 2007 17:31:47 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Apr 2007 10:31:47 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of wes.garland@gmail.com designates 64.233.184.235 as permitted sender) Received: from [64.233.184.235] (HELO wr-out-0506.google.com) (64.233.184.235) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 16 Apr 2007 10:31:39 -0700 Received: by wr-out-0506.google.com with SMTP id 70so1636035wra for ; Mon, 16 Apr 2007 10:31:18 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:mime-version:content-type:x-google-sender-auth; b=UpDBS9FB2dbdkBwVYxBFVw+uI8kLPfECswZC6Ccc3cwHXlvqs0kKmrEZlL6gymSrvU4dX2+dRqcR4ZDAKSzkx8AoXsN4fy/KE7HHZYYHGXsjAZY/qgnNHn69AIL9vMob+LX1frLZ5+pz0HJ3Nfhlcj7dGex4BGxiMvwwLOtq0jg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:mime-version:content-type:x-google-sender-auth; b=XSngw5M78DRtbLIzD7gWacD7rCRIvHzCjCQVVvkOrko6KpSan9l5ZjW18H7JG2BicH+0AHwRbHnyluAhZhdk8L/XrEPgDvGCqvPFA9ZQm950+Um8sJM7xDli+/JTkjxaWcf7TqpHfa4R2cnXdRcq0xT+pOViW6B+Mi0pICSfL9k= Received: by 10.114.198.1 with SMTP id v1mr2003023waf.1176744678290; Mon, 16 Apr 2007 10:31:18 -0700 (PDT) Received: by 10.114.61.9 with HTTP; Mon, 16 Apr 2007 10:31:18 -0700 (PDT) Message-ID: Date: Mon, 16 Apr 2007 13:31:18 -0400 From: "Wesley W. Garland" Sender: wes.garland@gmail.com To: "APR Development List" Subject: Interesting apr_proc_create() / apr_file_mktemp() interaction MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_46103_30388071.1176744678233" X-Google-Sender-Auth: 52ed547453763fde X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_46103_30388071.1176744678233 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline List: I found an interesting interaction between apr_proc_create() and apr_file_mktemp() today. I'm not sure if it should be classified as an *actual* bug, or a silly feature which needs to be documented. Consider this snippet: file = apr_file_mktemp(); proc = apr_proc_create(); stat(the_filename) = ENOENT. Why? The apr_file_t * returned by apr_file_mktemp() is registered in its pool as delete-on-close. apr_proc_create closes all opened files after fork() and before execve() (presumably by destroying the top-level pool? Maybe via atexit()?) Anyhow, the net effect is a really unexpectedly deleted file by the parent process. How did I find this? I was using an apr_file_mktemp() file to schedule a job with at. By the time at ran, the file with the commands to schedule had been erase! FWIW, this is on Solaris 8 / Sparc. The unlink() system call is actually called immediately after the file descriptor closes. Verified using truss -f. Which raises another tiny question, shouldn't the file be unlink()ed *before* it's close()d? That would unable any apr_file_lock() locks on the file to stay "active" until it was gone, meaning that no other process could touch it.. at least, another process that uses advisory file locking in NON-BLOCKING mode. Comments? Wes -- Wesley W. Garland Director, Product Development PageMail, Inc. +1 613 542 2787 x 102 ------=_Part_46103_30388071.1176744678233 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline List:

I found an interesting interaction between apr_proc_create() and apr_file_mktemp() today. I'm not sure if it should be classified as an *actual* bug, or a silly feature which needs to be documented. Consider this snippet:

file = apr_file_mktemp();
proc = apr_proc_create();
stat(the_filename) = ENOENT.

Why?

The apr_file_t * returned by apr_file_mktemp() is registered in its pool as delete-on-close.  apr_proc_create closes all opened files after fork() and before execve() (presumably by destroying the top-level pool? Maybe via atexit()?)

Anyhow, the net effect is a really unexpectedly deleted file by the parent process.

How did I find this? I was using an apr_file_mktemp() file to schedule a job with at. By the time at ran, the file with the commands to schedule had been erase!

FWIW, this is on Solaris 8 / Sparc.  The unlink() system call is actually called immediately after the file descriptor closes. Verified using truss -f.

Which raises another tiny question, shouldn't the file be unlink()ed *before* it's close()d?  That would unable any apr_file_lock() locks on the file to stay "active" until it was gone, meaning that no other process could touch it.. at least, another process that uses advisory file locking in NON-BLOCKING mode.

Comments?

Wes

--
Wesley W. Garland
Director, Product Development
PageMail, Inc.
+1 613 542 2787 x 102 ------=_Part_46103_30388071.1176744678233--