apr-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 41119] New: - apr_pool_cleanup_for_exec *do* flush I/O buffers
Date Wed, 06 Dec 2006 19:45:58 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=41119>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=41119

           Summary: apr_pool_cleanup_for_exec *do* flush I/O buffers
           Product: APR
           Version: 1.2.7
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: APR
        AssignedTo: bugs@apr.apache.org
        ReportedBy: jeffwu75@gmail.com


/**
 * Run all registered child cleanups, in preparation for an exec()
 * call in a forked child -- close files, etc., but *don't* flush I/O
 * buffers, *don't* wait for subprocesses, and *don't* free any
 * memory.
 */
APR_DECLARE(void) apr_pool_cleanup_for_exec(void);

Here is my simple test code to show this issue. After running this code,
/tmp/testfile will be 30 bytes instead of 20 bytes.

#include <apr_general.h>
#include <apr_thread_proc.h>
#include <unistd.h>
#include <stdlib.h>

int main(void)
{
    apr_size_t length, written;

    apr_pool_t *pool;
    apr_file_t *file;
    char *buf = "0123456789";

    apr_app_initialize(NULL,NULL,NULL);
    apr_pool_create(&pool, NULL);
    
    //system("rm -f /tmp/testfile");

    apr_file_open(&file, "/tmp/testfile",
                    APR_CREATE | APR_WRITE | APR_BINARY |
                    APR_BUFFERED | APR_EXCL, 
		    APR_OS_DEFAULT, pool);
    length = 10;
    apr_file_write_full(file, buf, length, &written);

    apr_proc_t *child;
    apr_procattr_t *child_attr;
    child = (apr_proc_t *)apr_pcalloc(pool, sizeof(*child));
    apr_procattr_create(&child_attr, pool);
    
    char *args[] = {"/bin/ls", NULL};
    apr_proc_create(child, "/bin/ls", args, NULL, child_attr, pool);

    //sleep(5);
    length = 10;
    apr_file_write_full(file, buf, length, &written);
    apr_file_close(file);

    apr_pool_destroy(pool);
    pool = NULL;
    apr_terminate();

    return 0;
}

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@apr.apache.org
For additional commands, e-mail: bugs-help@apr.apache.org


Mime
View raw message