From owner-FreeBSD-tech-jp@jp.freebsd.org  Sat Dec 11 04:25:54 1999
Received: (from daemon@localhost)
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) id EAA27978;
	Sat, 11 Dec 1999 04:25:54 +0900 (JST)
	(envelope-from owner-FreeBSD-tech-jp@jp.FreeBSD.org)
Received: from ms1.din.or.jp (ms1.din.or.jp [210.135.65.21])
	by castle.jp.freebsd.org (8.9.3+3.2W/8.7.3) with ESMTP id EAA27973
	for <FreeBSD-tech-jp@jp.freebsd.org>; Sat, 11 Dec 1999 04:25:53 +0900 (JST)
	(envelope-from tshiozak@din.or.jp)
Received: from localhost (ppp10-099.din.or.jp [210.135.74.130])
	by ms1.din.or.jp (8.9.3/3.7W) with ESMTP id EAA10055
	for <FreeBSD-tech-jp@jp.freebsd.org>; Sat, 11 Dec 1999 04:25:51 +0900 (JST)
To: FreeBSD-tech-jp@jp.freebsd.org
From: "T.SHIOZAKI" <AoiMoe@imou.to>
X-Mailer: Mew version 1.95b3 on Emacs 20.5 / Mule 4.0 (HANANOEN)
X-Prom-Mew: Prom-Mew 1.93.2 (procmail reader for Mew)
X-My-Web-Root: http://www.imou.to/~AoiMoe/
X-Organization: I18n/M17n Operating task force for Unix (IMOU)
X-FYI: X-TT Ver1.3.0 is available!!
Mime-Version: 1.0
Content-Type: Multipart/Mixed;
 boundary="--Next_Part(Sat_Dec_11_04:27:16_1999_595)--"
Content-Transfer-Encoding: 7bit
Message-Id: <19991211042818V.tshiozak@din.or.jp>
Date: Sat, 11 Dec 1999 04:28:18 +0900
X-Dispatcher: imput version 991025(IM133)
Lines: 144
Reply-To: FreeBSD-tech-jp@jp.freebsd.org
Precedence: list
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+990727
X-Sequence: FreeBSD-tech-jp 2648
Subject: [FreeBSD-tech-jp 2648] Invoke external application from communicator
Errors-To: owner-FreeBSD-tech-jp@jp.freebsd.org
Sender: owner-FreeBSD-tech-jp@jp.freebsd.org
X-Originator: tshiozak@din.or.jp

----Next_Part(Sat_Dec_11_04:27:16_1999_595)--
Content-Type: Text/Plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit


$B1v:j$G$9!#(B


$B$?$^$K!"!V(Bxpg4-ns $B$r(B preload $B$7$?(B netscape communicator $B$G(B
$B30It%"%W%j%1!<%7%g%s$r8F$S=P$9$H%3%1$k!W$H$$$&<ALd$H!"$=$l$KBP$9$k(B
$B!V%"%W%j%1!<%7%g%s$N%3%^%s%I%i%$%s$N@_Dj$G(BLD_PRELOAD $B$r6u$K$9$k$HNI$$!W(B
$B$H$$$&2sEz$r8+3]$1$k$N$G!"$A$g$C$H$U$K$U$K!#(B

# $B$b$H$b$H!"(BLinux $B$GF1<o$NLdBj$K%V%AEv$?$C$F2sHrITG=$@$C$?$+$i(B
# $B9M$($?:v$@$C$?$j$9$k!#(B


$BE:IU$7$?(B C $B%U%!%$%k$r(B xpg4-ns $B$H0l=o$K(B preload $B$9$k$H9,$;$K$J$l$^$9!#(B
$B0lIt$N?M$O!V$&!"$3$s$J$b$s(B preload $B$9$k$J!W$HIT2w$K$J$k$+$b$7$l$^$;$s$,(B :-)

# $B$G$b!"$I!<$;!"$9$G$K(B libxpg4 $B$K<j$rF~$l$F(B preload $B$7$F$k$s$@$7!"(B
# $B$b$O$d$3$l0J>e$5$i$K2?$+$r(B preload $B$7$F$b@:?@1R@8>e$5$7$FJQ$o$i$s$h$M(B :-P


$B$J$*!"(BFreeBSD-3.2R cc/ld on NetBSD-1.4P $B$G%3%s%Q%$%k$G$-$k$3$H$O(B
$B3NG'$7$F$^$9$,!"(BFreeBSD $B%M%$%F%#%V$G$O3NG'$7$F$^$;$s$N$G$"$7$+$i$:!#(B


$B$G$O!#(B

--
Takuya SHIOZAKI - chair of IMOU.

----Next_Part(Sat_Dec_11_04:27:16_1999_595)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="system.c"

/*
 * Copyright (c) 1988, 1993
 *	The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by the University of
 *	California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)system.c	8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */

#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include <stdlib.h>
#include <stddef.h>
#include <unistd.h>
#include <paths.h>
#include <errno.h>

int system(command)
	const char *command;
{
	pid_t pid;
	int pstat;
	struct sigaction ign, intact, quitact;
	sigset_t newsigblock, oldsigblock;

	if (!command)		/* just checking... */
		return(1);

	/*
	 * Ignore SIGINT and SIGQUIT, block SIGCHLD. Remember to save
	 * existing signal dispositions.
	 */
	ign.sa_handler = SIG_IGN;
	(void)sigemptyset(&ign.sa_mask);
	ign.sa_flags = 0;
	(void)sigaction(SIGINT, &ign, &intact);
	(void)sigaction(SIGQUIT, &ign, &quitact);
	(void)sigemptyset(&newsigblock);
	(void)sigaddset(&newsigblock, SIGCHLD);
	(void)sigprocmask(SIG_BLOCK, &newsigblock, &oldsigblock);
	switch(pid = fork()) {
	case -1:			/* error */
		break;
	case 0:				/* child */
		/*
		 * Restore original signal dispositions and exec the command.
		 */
		(void)sigaction(SIGINT, &intact, NULL);
		(void)sigaction(SIGQUIT,  &quitact, NULL);
		(void)sigprocmask(SIG_SETMASK, &oldsigblock, NULL);
                {
                    /* revoking LD_PRELOAD environment variable */
                    extern char **environ;
                    char **p;
                    for (p=environ; *p; p++) {
                        if ( !strncmp(*p, "LD_PRELOAD",
                                      sizeof("LD_PRELOAD")-1) ) {
                            *p = "LD_PRELOAD=";
                            break;
                        }
                    }
                }
		execl(_PATH_BSHELL, "sh", "-c", command, (char *)NULL);
		_exit(127);
	default:			/* parent */
		do {
			pid = waitpid(pid, &pstat, 0);
		} while (pid == -1 && errno == EINTR);
		break;
	}
	(void)sigaction(SIGINT, &intact, NULL);
	(void)sigaction(SIGQUIT,  &quitact, NULL);
	(void)sigprocmask(SIG_SETMASK, &oldsigblock, NULL);
	return(pid == -1 ? -1 : pstat);
}

----Next_Part(Sat_Dec_11_04:27:16_1999_595)----
