popen.c revision 59f081ed215eb7d3fbf19cce3474b2987eaf3225
1022N/A * The contents of this file are subject to the terms of the 1022N/A * Common Development and Distribution License (the "License"). 1022N/A * You may not use this file except in compliance with the License. 1022N/A * See the License for the specific language governing permissions 1022N/A * and limitations under the License. 1022N/A * When distributing Covered Code, include this CDDL HEADER in each 1022N/A * If applicable, add the following below this CDDL HEADER, with the 1022N/A * fields enclosed by brackets "[]" replaced with your own identifying 1022N/A * information: Portions Copyright [yyyy] [name of copyright owner] 1022N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 1022N/A * Use is subject to license terms. 1022N/A/* Copyright (c) 1988 AT&T */ 1022N/A#
pragma ident "%Z%%M% %I% %E% SMI" 1056N/A * Cancellation cleanup handler. 1056N/A * If we were cancelled in waitpid(), create a daemon thread to 1056N/A * reap our abandoned child. No other thread can do this for us. 1056N/A * We have been cancelled. There is no need to restore 1056N/A * the original sigmask after blocking all signals because 1056N/A * pthread_exit() will block all signals while we exit. 1056N/A /* myside and yourside reverse roles in child */ 1056N/A /* This will fail more quickly if we run out of fds */ 1056N/A /* in the child, close all pipes from other popen's */ 1056N/A * These conditions may apply if a previous iob returned 1022N/A * by popen() was closed with fclose() rather than pclose(), 1022N/A * or if close(fileno(iob)) was called. Don't let these 1022N/A * programming errors cause us to malfunction here. 1022N/A * pclose() is a cancellation point. 1056N/A /* mark this pipe closed */ 1056N/A * waitpid() is a cancellation point. 1056N/A * This causes pclose() to be a cancellation point. 1056N/A * If we have already been cancelled (pclose() was called from 1056N/A * a cancellation cleanup handler), attempt to reap the process 1056N/A * w/o waiting, and if that fails just call cleanup(pid). 1056N/A /* waitpid(..., WNOHANG) is not a cancellation point */ 1032N/A * curr->fd can equal fd if a previous iob returned by 1032N/A * popen() was closed with fclose() rather than pclose(), 1032N/A * or if close(fileno(iob)) was called. Don't let these 1032N/A * programming errors cause us to malfunction here. 1032N/A /* make a lame attempt to reap the forgotten child */ 1056N/A * _insert() and _delete() are used by p2open() in libgen.