jdk/src/windows/native/java/lang/ProcessImpl_md.c
author ohair
Tue, 28 Dec 2010 15:53:50 -0800
changeset 7668 d4a77089c587
parent 7515 43202796198e
child 13149 27d52f97a5cc
permissions -rw-r--r--
6962318: Update copyright year Reviewed-by: xdono
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
7668
d4a77089c587 6962318: Update copyright year
ohair
parents: 7515
diff changeset
     2
 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5168
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5168
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5168
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5168
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5168
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#include <assert.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#include "java_lang_ProcessImpl.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "jni.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include "jvm.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include "jni_util.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include "io_util.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include <windows.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include <io.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
43
bfccfd41f0fc 6631966: (process) Raise Windows pipe buffer size an extra 24 bytes (win)
martin
parents: 2
diff changeset
    36
/* We try to make sure that we can read and write 4095 bytes (the
bfccfd41f0fc 6631966: (process) Raise Windows pipe buffer size an extra 24 bytes (win)
martin
parents: 2
diff changeset
    37
 * fixed limit on Linux) to the pipe on all operating systems without
bfccfd41f0fc 6631966: (process) Raise Windows pipe buffer size an extra 24 bytes (win)
martin
parents: 2
diff changeset
    38
 * deadlock.  Windows 2000 inexplicably appears to need an extra 24
bfccfd41f0fc 6631966: (process) Raise Windows pipe buffer size an extra 24 bytes (win)
martin
parents: 2
diff changeset
    39
 * bytes of slop to avoid deadlock.
bfccfd41f0fc 6631966: (process) Raise Windows pipe buffer size an extra 24 bytes (win)
martin
parents: 2
diff changeset
    40
 */
bfccfd41f0fc 6631966: (process) Raise Windows pipe buffer size an extra 24 bytes (win)
martin
parents: 2
diff changeset
    41
#define PIPE_SIZE (4096+24)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
char *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
extractExecutablePath(JNIEnv *env, char *source)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    char *p, *r;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    /* If no spaces, then use entire thing */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    if ((p = strchr(source, ' ')) == NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        return source;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    /* If no quotes, or quotes after space, return up to space */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    if (((r = strchr(source, '"')) == NULL) || (r > p)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        *p = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        return source;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    /* Quotes before space, return up to space after next quotes */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    p = strchr(r, '"');
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    if ((p = strchr(p, ' ')) == NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        return source;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    *p = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    return source;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
DWORD
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
selectProcessFlag(JNIEnv *env, jstring cmd0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    char buf[MAX_PATH];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    DWORD newFlag = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    char *exe, *p, *name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    unsigned char buffer[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    long headerLoc = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    int fd = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    exe = (char *)JNU_GetStringPlatformChars(env, cmd0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    exe = extractExecutablePath(env, exe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    if (exe != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
        if ((p = strchr(exe, '\\')) == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
            SearchPath(NULL, exe, ".exe", MAX_PATH, buf, &name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
            p = strrchr(exe, '\\');
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
            *p = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
            p++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
            SearchPath(exe, p, ".exe", MAX_PATH, buf, &name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    fd = _open(buf, _O_RDONLY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    if (fd > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        _read(fd, buffer, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        if (buffer[0] == 'M' && buffer[1] == 'Z') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            _lseek(fd, 60L, SEEK_SET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            _read(fd, buffer, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            headerLoc = (long)buffer[1] << 8 | (long)buffer[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
            _lseek(fd, headerLoc, SEEK_SET);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            _read(fd, buffer, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            if (buffer[0] == 'P' && buffer[1] == 'E') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                newFlag = DETACHED_PROCESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        _close(fd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    JNU_ReleaseStringPlatformChars(env, cmd0, exe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    return newFlag;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
win32Error(JNIEnv *env, const char *functionName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    static const char * const format = "%s error=%d, %s";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    static const char * const fallbackFormat = "%s failed, error=%d";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    char buf[256];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    char errmsg[sizeof(buf) + 100];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    const int errnum = GetLastError();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    const int n = JVM_GetLastErrorString(buf, sizeof(buf));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    if (n > 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        sprintf(errmsg, format, functionName, errnum, buf);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        sprintf(errmsg, fallbackFormat, functionName, errnum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    JNU_ThrowIOException(env, errmsg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
closeSafely(HANDLE handle)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
{
48
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   128
    if (handle != INVALID_HANDLE_VALUE)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        CloseHandle(handle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
Java_java_lang_ProcessImpl_create(JNIEnv *env, jclass ignored,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                                  jstring cmd,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                                  jstring envBlock,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                                  jstring dir,
48
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   137
                                  jlongArray stdHandles,
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   138
                                  jboolean redirectErrorStream)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
{
48
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   140
    HANDLE inRead   = INVALID_HANDLE_VALUE;
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   141
    HANDLE inWrite  = INVALID_HANDLE_VALUE;
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   142
    HANDLE outRead  = INVALID_HANDLE_VALUE;
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   143
    HANDLE outWrite = INVALID_HANDLE_VALUE;
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   144
    HANDLE errRead  = INVALID_HANDLE_VALUE;
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   145
    HANDLE errWrite = INVALID_HANDLE_VALUE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    SECURITY_ATTRIBUTES sa;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    PROCESS_INFORMATION pi;
5168
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
   148
    STARTUPINFOW si;
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
   149
    const jchar*  pcmd = NULL;
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
   150
    const jchar*  pdir = NULL;
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
   151
    const jchar*  penvBlock = NULL;
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
   152
    jlong  *handles = NULL;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    jlong ret = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    OSVERSIONINFO ver;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    jboolean onNT = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    DWORD processFlag;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    ver.dwOSVersionInfoSize = sizeof(ver);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    GetVersionEx(&ver);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    if (ver.dwPlatformId == VER_PLATFORM_WIN32_NT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        onNT = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    assert(cmd != NULL);
5168
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
   164
    pcmd = (*env)->GetStringChars(env, cmd, NULL);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    if (pcmd == NULL) goto Catch;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    if (dir != 0) {
5168
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
   168
        pdir = (*env)->GetStringChars(env, dir, NULL);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        if (pdir == NULL) goto Catch;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    if (envBlock != NULL) {
5168
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
   172
        penvBlock = ((*env)->GetStringChars(env, envBlock, NULL));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        if (penvBlock == NULL) goto Catch;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    }
48
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   175
    assert(stdHandles != NULL);
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   176
    handles = (*env)->GetLongArrayElements(env, stdHandles, NULL);
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   177
    if (handles == NULL) goto Catch;
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   178
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    memset(&si, 0, sizeof(si));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    si.cb = sizeof(si);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    si.dwFlags = STARTF_USESTDHANDLES;
48
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   182
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   183
    sa.nLength = sizeof(sa);
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   184
    sa.lpSecurityDescriptor = 0;
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   185
    sa.bInheritHandle = TRUE;
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   186
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   187
    if (handles[0] != (jlong) -1) {
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   188
        si.hStdInput = (HANDLE) handles[0];
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   189
        handles[0] = (jlong) -1;
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   190
    } else {
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   191
        if (! CreatePipe(&inRead,  &inWrite,  &sa, PIPE_SIZE)) {
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   192
            win32Error(env, "CreatePipe");
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   193
            goto Catch;
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   194
        }
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   195
        si.hStdInput = inRead;
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   196
        SetHandleInformation(inWrite, HANDLE_FLAG_INHERIT, FALSE);
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   197
        handles[0] = (jlong) inWrite;
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   198
    }
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   199
    SetHandleInformation(si.hStdInput, HANDLE_FLAG_INHERIT, TRUE);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
48
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   201
    if (handles[1] != (jlong) -1) {
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   202
        si.hStdOutput = (HANDLE) handles[1];
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   203
        handles[1] = (jlong) -1;
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   204
    } else {
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   205
        if (! CreatePipe(&outRead, &outWrite, &sa, PIPE_SIZE)) {
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   206
            win32Error(env, "CreatePipe");
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   207
            goto Catch;
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   208
        }
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   209
        si.hStdOutput = outWrite;
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   210
        SetHandleInformation(outRead, HANDLE_FLAG_INHERIT, FALSE);
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   211
        handles[1] = (jlong) outRead;
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   212
    }
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   213
    SetHandleInformation(si.hStdOutput, HANDLE_FLAG_INHERIT, TRUE);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
48
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   215
    if (redirectErrorStream) {
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   216
        si.hStdError = si.hStdOutput;
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   217
        handles[2] = (jlong) -1;
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   218
    } else if (handles[2] != (jlong) -1) {
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   219
        si.hStdError = (HANDLE) handles[2];
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   220
        handles[2] = (jlong) -1;
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   221
    } else {
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   222
        if (! CreatePipe(&errRead, &errWrite, &sa, PIPE_SIZE)) {
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   223
            win32Error(env, "CreatePipe");
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   224
            goto Catch;
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   225
        }
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   226
        si.hStdError = errWrite;
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   227
        SetHandleInformation(errRead, HANDLE_FLAG_INHERIT, FALSE);
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   228
        handles[2] = (jlong) errRead;
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   229
    }
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   230
    SetHandleInformation(si.hStdError, HANDLE_FLAG_INHERIT, TRUE);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    if (onNT)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        processFlag = CREATE_NO_WINDOW | CREATE_UNICODE_ENVIRONMENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    else
5168
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
   235
        processFlag = selectProcessFlag(env, cmd) | CREATE_UNICODE_ENVIRONMENT;
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
   236
    ret = CreateProcessW(0,                /* executable name */
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
   237
                         (LPWSTR)pcmd,     /* command line */
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
   238
                         0,                /* process security attribute */
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
   239
                         0,                /* thread security attribute */
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
   240
                         TRUE,             /* inherits system handles */
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
   241
                         processFlag,      /* selected based on exe type */
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
   242
                         (LPVOID)penvBlock,/* environment block */
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
   243
                         (LPCWSTR)pdir,    /* change to the new current directory */
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
   244
                         &si,              /* (in)  startup information */
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
   245
                         &pi);             /* (out) process information */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    if (!ret) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        win32Error(env, "CreateProcess");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        goto Catch;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    CloseHandle(pi.hThread);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    ret = (jlong)pi.hProcess;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
 Finally:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    /* Always clean up the child's side of the pipes */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    closeSafely(inRead);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    closeSafely(outWrite);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    closeSafely(errWrite);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    if (pcmd != NULL)
5168
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
   261
        (*env)->ReleaseStringChars(env, cmd, pcmd);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    if (pdir != NULL)
5168
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
   263
        (*env)->ReleaseStringChars(env, dir, pdir);
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
   264
    if (penvBlock != NULL)
41e46b5d9b15 4947220: (process)Runtime.exec() cannot invoke applications with unicode parameters(win)
sherman
parents: 715
diff changeset
   265
        (*env)->ReleaseStringChars(env, envBlock, penvBlock);
48
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   266
    if (handles != NULL)
dc5744ca15ea 4960438: (process) Need IO redirection API for subprocesses
martin
parents: 43
diff changeset
   267
        (*env)->ReleaseLongArrayElements(env, stdHandles, handles, 0);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    return ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
 Catch:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    /* Clean up the parent's side of the pipes in case of failure only */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    closeSafely(inWrite);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    closeSafely(outRead);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    closeSafely(errRead);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    goto Finally;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
Java_java_lang_ProcessImpl_getExitCodeProcess(JNIEnv *env, jclass ignored, jlong handle)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    DWORD exit_code;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    if (GetExitCodeProcess((HANDLE) handle, &exit_code) == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        win32Error(env, "GetExitCodeProcess");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    return exit_code;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
Java_java_lang_ProcessImpl_getStillActive(JNIEnv *env, jclass ignored)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    return STILL_ACTIVE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
Java_java_lang_ProcessImpl_waitForInterruptibly(JNIEnv *env, jclass ignored, jlong handle)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    HANDLE events[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    events[0] = (HANDLE) handle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    events[1] = JVM_GetThreadInterruptEvent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    if (WaitForMultipleObjects(sizeof(events)/sizeof(events[0]), events,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                               FALSE,    /* Wait for ANY event */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
                               INFINITE) /* Wait forever */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        == WAIT_FAILED)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        win32Error(env, "WaitForMultipleObjects");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
Java_java_lang_ProcessImpl_terminateProcess(JNIEnv *env, jclass ignored, jlong handle)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    TerminateProcess((HANDLE) handle, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
Java_java_lang_ProcessImpl_closeHandle(JNIEnv *env, jclass ignored, jlong handle)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    return CloseHandle((HANDLE) handle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
}
7515
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   318
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   319
/**
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   320
 * Returns a copy of the Unicode characters of a string. Fow now this
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   321
 * function doesn't handle long path names and other issues.
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   322
 */
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   323
static WCHAR* getPath(JNIEnv *env, jstring ps) {
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   324
    WCHAR *pathbuf = NULL;
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   325
    const jchar *chars = (*(env))->GetStringChars(env, ps, NULL);
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   326
    if (chars != NULL) {
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   327
        size_t pathlen = wcslen(chars);
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   328
        pathbuf = (WCHAR*)malloc((pathlen + 6) * sizeof(WCHAR));
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   329
        if (pathbuf == NULL) {
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   330
            JNU_ThrowOutOfMemoryError(env, NULL);
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   331
        } else {
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   332
            wcscpy(pathbuf, chars);
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   333
        }
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   334
        (*env)->ReleaseStringChars(env, ps, chars);
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   335
    }
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   336
    return pathbuf;
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   337
}
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   338
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   339
JNIEXPORT jlong JNICALL
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   340
Java_java_lang_ProcessImpl_openForAtomicAppend(JNIEnv *env, jclass ignored, jstring path)
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   341
{
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   342
    const DWORD access = (FILE_GENERIC_WRITE & ~FILE_WRITE_DATA);
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   343
    const DWORD sharing = FILE_SHARE_READ | FILE_SHARE_WRITE;
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   344
    const DWORD disposition = OPEN_ALWAYS;
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   345
    const DWORD flagsAndAttributes = FILE_ATTRIBUTE_NORMAL;
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   346
    HANDLE h;
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   347
    WCHAR *pathbuf = getPath(env, path);
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   348
    if (pathbuf == NULL) {
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   349
        /* Exception already pending */
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   350
        return -1;
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   351
    }
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   352
    h = CreateFileW(
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   353
        pathbuf,            /* Wide char path name */
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   354
        access,             /* Read and/or write permission */
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   355
        sharing,            /* File sharing flags */
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   356
        NULL,               /* Security attributes */
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   357
        disposition,        /* creation disposition */
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   358
        flagsAndAttributes, /* flags and attributes */
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   359
        NULL);
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   360
    free(pathbuf);
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   361
    if (h == INVALID_HANDLE_VALUE) {
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   362
        JNU_ThrowIOExceptionWithLastError(env, "CreateFileW");
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   363
    }
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   364
    return ptr_to_jlong(h);
43202796198e 6709457: (fc) lock/tryLock() throws IOException "Access is denied" when file opened for append [win]
alanb
parents: 5506
diff changeset
   365
}