popen.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
#include "synonyms.h"
#include "mtlib.h"
#include "file64.h"
#include <stdio.h>
#include <stdlib.h>
#include <wait.h>
#include <signal.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <thread.h>
#include <synch.h>
#include <spawn.h>
#include "stdiom.h"
#include "mse.h"
#include "libc.h"
#define RDR 0
#define WTR 1
#ifndef _LP64
#endif /* _LP64 */
static int _insert_nolock(pid_t, int);
extern const char **environ;
typedef struct node {
int fd;
} node_t;
FILE *
{
int p[2];
const char *shpath;
int stdio;
char *argvec[4];
int error;
static const char *shell = "sh";
static const char *sh_flg = "-c";
if (pipe(p) < 0)
return (NULL);
#ifndef _LP64
/* check that the fd's are in range for a struct FILE */
return (NULL);
}
#endif /* _LP64 */
/* myside and yourside reverse roles in child */
/* in the child, close all pipes from other popen's */
return (NULL);
}
if (error == 0)
if (error == 0)
if (error == 0)
yourside);
}
if (error) {
(void) posix_spawn_file_actions_destroy(&fact);
return (NULL);
}
(void) posix_spawn_file_actions_destroy(&fact);
return (NULL);
}
return (NULL);
}
return (iop);
}
int
{
int status;
/* mark this pipe closed */
if (pid == -1)
return (-1);
/* If waitpid fails with EINTR, restart the waitpid call */
status = -1;
break;
}
}
return (status);
}
static int
{
return (-1);
else
return (0);
}
/*
* _insert() and _delete() are used by p2open() in libgen.
*/
int
{
int rc;
return (rc);
}
{
else
return (pid);
}
}
return (-1);
}