Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/solaris/native/java/lang/childproc.h
32287 views
/*1* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#ifndef CHILDPROC_MD_H26#define CHILDPROC_MD_H2728#include <sys/types.h>2930#ifdef __APPLE__31#include <crt_externs.h>32#define environ (*_NSGetEnviron())33#else34/* This is one of the rare times it's more portable to declare an35* external symbol explicitly, rather than via a system header.36* The declaration is standardized as part of UNIX98, but there is37* no standard (not even de-facto) header file where the38* declaration is to be found. See:39* http://www.opengroup.org/onlinepubs/009695399/functions/environ.html40* http://www.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_02.html41*42* "All identifiers in this volume of IEEE Std 1003.1-2001, except43* environ, are defined in at least one of the headers" (!)44*/45extern char **environ;46#endif4748#ifdef __linux__49#include <sched.h>50#endif5152#ifndef STDIN_FILENO53#define STDIN_FILENO 054#endif5556#ifndef STDOUT_FILENO57#define STDOUT_FILENO 158#endif5960#ifndef STDERR_FILENO61#define STDERR_FILENO 262#endif6364#ifndef SA_NOCLDSTOP65#define SA_NOCLDSTOP 066#endif6768#ifndef SA_RESTART69#define SA_RESTART 070#endif7172#define FAIL_FILENO (STDERR_FILENO + 1)7374/* TODO: Refactor. */75#define RESTARTABLE(_cmd, _result) do { \76do { \77_result = _cmd; \78} while((_result == -1) && (errno == EINTR)); \79} while(0)8081/* These numbers must be the same as the Enum in UNIXProcess.java82* Must be a better way of doing this.83*/84#define MODE_FORK 185#define MODE_POSIX_SPAWN 286#define MODE_VFORK 387#define MODE_CLONE 48889typedef struct _ChildStuff90{91int in[2];92int out[2];93int err[2];94int fail[2];95int childenv[2];96int fds[3];97int mode;98const char **argv;99int argc;100const char **envv;101const char *pdir;102int redirectErrorStream;103void *clone_stack;104} ChildStuff;105106/* following used in addition when mode is SPAWN */107typedef struct _SpawnInfo {108int nargv; /* number of argv array elements */109int argvBytes; /* total number of bytes in argv array */110int nenvv; /* number of envv array elements */111int envvBytes; /* total number of bytes in envv array */112int dirlen; /* length of home directory string */113int nparentPathv; /* number of elements in parentPathv array */114int parentPathvBytes; /* total number of bytes in parentPathv array */115} SpawnInfo;116117/**118* The cached and split version of the JDK's effective PATH.119* (We don't support putenv("PATH=...") in native code)120*/121extern const char * const *parentPathv;122123ssize_t restartableWrite(int fd, const void *buf, size_t count);124int restartableDup2(int fd_from, int fd_to);125int closeSafely(int fd);126int isAsciiDigit(char c);127int closeDescriptors(void);128int moveDescriptor(int fd_from, int fd_to);129130int magicNumber();131ssize_t readFully(int fd, void *buf, size_t nbyte);132void initVectorFromBlock(const char**vector, const char* block, int count);133void execve_as_traditional_shell_script(const char *file,134const char *argv[],135const char *const envp[]);136void execve_with_shell_fallback(int mode, const char *file,137const char *argv[],138const char *const envp[]);139void JDK_execvpe(int mode, const char *file,140const char *argv[],141const char *const envp[]);142int childProcess(void *arg);143144#endif145146147