< prev index next >

jdk/src/java.base/unix/native/libjava/ProcessImpl_md.c

Print this page




 135 {
 136     void *p = malloc(size);
 137     if (p == NULL)
 138         JNU_ThrowOutOfMemoryError(env, NULL);
 139     return p;
 140 }
 141 
 142 #define NEW(type, n) ((type *) xmalloc(env, (n) * sizeof(type)))
 143 
 144 /**
 145  * If PATH is not defined, the OS provides some default value.
 146  * Unfortunately, there's no portable way to get this value.
 147  * Fortunately, it's only needed if the child has PATH while we do not.
 148  */
 149 static const char*
 150 defaultPath(void)
 151 {
 152 #ifdef __solaris__
 153     /* These really are the Solaris defaults! */
 154     return (geteuid() == 0 || getuid() == 0) ?
 155         "/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/SUNWspro/bin:/usr/sbin" :
 156         "/usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/SUNWspro/bin:";
 157 #else
 158     return ":/bin:/usr/bin";    /* glibc */
 159 #endif
 160 }
 161 
 162 static const char*
 163 effectivePath(void)
 164 {
 165     const char *s = getenv("PATH");
 166     return (s != NULL) ? s : defaultPath();
 167 }
 168 
 169 static int
 170 countOccurrences(const char *s, char c)
 171 {
 172     int count;
 173     for (count = 0; *s != '\0'; s++)
 174         count += (*s == c);
 175     return count;
 176 }




 135 {
 136     void *p = malloc(size);
 137     if (p == NULL)
 138         JNU_ThrowOutOfMemoryError(env, NULL);
 139     return p;
 140 }
 141 
 142 #define NEW(type, n) ((type *) xmalloc(env, (n) * sizeof(type)))
 143 
 144 /**
 145  * If PATH is not defined, the OS provides some default value.
 146  * Unfortunately, there's no portable way to get this value.
 147  * Fortunately, it's only needed if the child has PATH while we do not.
 148  */
 149 static const char*
 150 defaultPath(void)
 151 {
 152 #ifdef __solaris__
 153     /* These really are the Solaris defaults! */
 154     return (geteuid() == 0 || getuid() == 0) ?
 155         "/usr/xpg4/bin:/usr/bin:/opt/SUNWspro/bin:/usr/sbin" :
 156         "/usr/xpg4/bin:/usr/bin:/opt/SUNWspro/bin:";
 157 #else
 158     return ":/bin:/usr/bin";    /* glibc */
 159 #endif
 160 }
 161 
 162 static const char*
 163 effectivePath(void)
 164 {
 165     const char *s = getenv("PATH");
 166     return (s != NULL) ? s : defaultPath();
 167 }
 168 
 169 static int
 170 countOccurrences(const char *s, char c)
 171 {
 172     int count;
 173     for (count = 0; *s != '\0'; s++)
 174         count += (*s == c);
 175     return count;
 176 }


< prev index next >