This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 201733
Collapse All | Expand All

(-)a/dlight.nativeexecution/tools/PtySupport/src/error.c (-1 / +7 lines)
Lines 1-15 Link Here
1
#include "error.h"
1
#include "error.h"
2
2
3
extern const char* progname;
4
3
/*
5
/*
4
 * Print a message and return to caller.
6
 * Print a message and return to caller.
5
 * Caller specifies "errnoflag".
7
 * Caller specifies "errnoflag".
6
 */
8
 */
7
static void err_doit(int errnoflag, int error, const char *fmt, va_list ap) {
9
static void err_doit(int errnoflag, int error, const char *fmt, va_list ap) {
8
    char buf[MAXLINE];
10
    char buf[MAXLINE];
9
    vsnprintf(buf, MAXLINE, fmt, ap);
11
12
    snprintf(buf, MAXLINE, "%s: ", progname);
13
    vsnprintf(buf + strlen(buf), MAXLINE, fmt, ap);
14
10
    if (errnoflag) {
15
    if (errnoflag) {
11
        snprintf(buf + strlen(buf), MAXLINE - strlen(buf), ": %s", strerror(error));
16
        snprintf(buf + strlen(buf), MAXLINE - strlen(buf), ": %s", strerror(error));
12
    }
17
    }
18
13
    strcat(buf, "\n");
19
    strcat(buf, "\n");
14
    fflush(stdout); /* in case stdout and stderr are the same */
20
    fflush(stdout); /* in case stdout and stderr are the same */
15
    fputs(buf, stderr);
21
    fputs(buf, stderr);
(-)a/dlight.nativeexecution/tools/PtySupport/src/loop.c (-22 / +24 lines)
Lines 1-4 Link Here
1
#include "loop.h"
1
#include "loop.h"
2
#include "error.h"
2
#include <poll.h>
3
#include <poll.h>
3
#include <sys/termios.h>
4
#include <sys/termios.h>
4
#include <stdio.h>
5
#include <stdio.h>
Lines 26-40 Link Here
26
        FD_SET(master_fd, &read_set);
27
        FD_SET(master_fd, &read_set);
27
        select_result = select(master_fd + 1, &read_set, NULL, NULL, NULL);
28
        select_result = select(master_fd + 1, &read_set, NULL, NULL, NULL);
28
29
30
        // interrupted select is ignored - see CR 7086177
31
        if (select_result == -1 && errno == EINTR) {
32
            continue;
33
        }
34
        
29
        if (select_result == -1) {
35
        if (select_result == -1) {
30
            printf("ERROR: poll failed\n");
36
            err_sys("poll failed\n");
31
            exit(1);
32
        }
37
        }
33
38
34
        if (FD_ISSET(STDIN_FILENO, &read_set)) {
39
        if (FD_ISSET(STDIN_FILENO, &read_set)) {
35
            if ((n = read(STDIN_FILENO, buf, BUFSIZ)) == -1) {
40
            if ((n = read(STDIN_FILENO, buf, BUFSIZ)) == -1) {
36
                printf("ERROR: read from stdin failed\n");
41
                err_sys("read from stdin failed\n");
37
                exit(1);
38
            }
42
            }
39
43
40
            if (n == 0) {
44
            if (n == 0) {
Lines 42-56 Link Here
42
            }
46
            }
43
47
44
            if (write(master_fd, buf, n) == -1) {
48
            if (write(master_fd, buf, n) == -1) {
45
                printf("ERROR: write to master failed\n");
49
                err_sys("write to master failed\n");
46
                exit(1);
47
            }
50
            }
48
        }
51
        }
49
52
50
        if (FD_ISSET(master_fd, &read_set)) {
53
        if (FD_ISSET(master_fd, &read_set)) {
51
            if ((n = read(master_fd, buf, BUFSIZ)) == -1) {
54
            if ((n = read(master_fd, buf, BUFSIZ)) == -1) {
52
                printf("ERROR: read from master failed\n");
55
                err_sys("read from master failed\n");
53
                exit(1);
54
            }
56
            }
55
57
56
            if (n == 0) {
58
            if (n == 0) {
Lines 58-69 Link Here
58
            }
60
            }
59
61
60
            if (write(STDOUT_FILENO, buf, n) == -1) {
62
            if (write(STDOUT_FILENO, buf, n) == -1) {
61
                printf("ERROR: write to stdout failed\n");
63
                err_sys("write to stdout failed\n");
62
                exit(1);
64
                exit(1);
63
            }
65
            }
64
        }
66
        }
65
    }
67
    }
66
    
68
67
    return 0;
69
    return 0;
68
}
70
}
69
71
Lines 86-100 Link Here
86
    for (;;) {
88
    for (;;) {
87
        poll_result = poll((struct pollfd*) & fds, 2, INFTIM);
89
        poll_result = poll((struct pollfd*) & fds, 2, INFTIM);
88
90
91
        // interrupted poll is ignored - see CR 7086177
92
        if (poll_result == -1 && errno == EINTR) {
93
            continue;
94
        }
95
89
        if (poll_result == -1) {
96
        if (poll_result == -1) {
90
            printf("ERROR: poll failed\n");
97
            err_sys("poll() failed in main_loop");
91
            exit(1);
92
        }
98
        }
93
99
94
        if (fds[0].revents & POLLIN) {
100
        if (fds[0].revents & POLLIN) {
95
            if ((n = read(STDIN_FILENO, buf, BUFSIZ)) == -1) {
101
            if ((n = read(STDIN_FILENO, buf, BUFSIZ)) == -1) {
96
                printf("ERROR: read from stdin failed\n");
102
                err_sys("read from stdin failed");
97
                exit(1);
98
            }
103
            }
99
104
100
            if (n == 0) {
105
            if (n == 0) {
Lines 109-123 Link Here
109
            }
114
            }
110
115
111
            if (writen(master_fd, buf, n) == -1) {
116
            if (writen(master_fd, buf, n) == -1) {
112
                printf("ERROR: write to master failed\n");
117
                err_sys("write to master failed\n");
113
                exit(1);
114
            }
118
            }
115
        }
119
        }
116
120
117
        if (fds[1].revents & POLLIN) {
121
        if (fds[1].revents & POLLIN) {
118
            if ((n = read(master_fd, buf, BUFSIZ)) == -1) {
122
            if ((n = read(master_fd, buf, BUFSIZ)) == -1) {
119
                printf("ERROR: read from master failed\n");
123
                err_sys("read from master failed\n");
120
                exit(1);
121
            }
124
            }
122
125
123
            if (n == 0) {
126
            if (n == 0) {
Lines 125-132 Link Here
125
            }
128
            }
126
129
127
            if (writen(STDOUT_FILENO, buf, n) == -1) {
130
            if (writen(STDOUT_FILENO, buf, n) == -1) {
128
                printf("ERROR: write to stdout failed\n");
131
                err_sys("write to stdout failed\n");
129
                exit(1);
130
            }
132
            }
131
        }
133
        }
132
134
Lines 145-151 Link Here
145
            return 1;
147
            return 1;
146
        }
148
        }
147
    }
149
    }
148
    
150
149
    return 0;
151
    return 0;
150
}
152
}
151
#endif
153
#endif
Lines 154-160 Link Here
154
    const char *pos = ptr;
156
    const char *pos = ptr;
155
    size_t nleft = n;
157
    size_t nleft = n;
156
    ssize_t nwritten;
158
    ssize_t nwritten;
157
    
159
158
    while (nleft > 0) {
160
    while (nleft > 0) {
159
        if ((nwritten = write(fd, pos, nleft)) < 0) {
161
        if ((nwritten = write(fd, pos, nleft)) < 0) {
160
            if (nleft == n)
162
            if (nleft == n)
(-)a/dlight.nativeexecution/tools/PtySupport/src/pty.c (-4 / +8 lines)
Lines 2-8 Link Here
2
 * File:   pty_start.c
2
 * File:   pty_start.c
3
 * Author: ak119685
3
 * Author: ak119685
4
 *
4
 *
5
 * Created on 22 Апрель 2010 г., 12:32
5
 * Created on 22 ?????? 2010 ?., 12:32
6
 */
6
 */
7
7
8
#include "pty_fork.h"
8
#include "pty_fork.h"
Lines 15-26 Link Here
15
#include <signal.h>
15
#include <signal.h>
16
#include <fcntl.h>
16
#include <fcntl.h>
17
17
18
#include <libgen.h>
19
18
#if defined __CYGWIN__ && !defined WCONTINUED
20
#if defined __CYGWIN__ && !defined WCONTINUED
19
//added for compatibility with cygwin 1.5
21
//added for compatibility with cygwin 1.5
20
#define WCONTINUED 0
22
#define WCONTINUED 0
21
#endif
23
#endif
22
24
23
static void set_noecho(int);
25
static void set_noecho(int);
26
const char* progname;
24
27
25
/*
28
/*
26
 * 
29
 * 
Lines 39-58 Link Here
39
    int idx;
42
    int idx;
40
    int nopt = 1;
43
    int nopt = 1;
41
44
45
    progname = basename(argv[0]);
46
42
    for (idx = 1; idx < argc; idx++) {
47
    for (idx = 1; idx < argc; idx++) {
43
        if (argv[idx][0] == '-') {
48
        if (argv[idx][0] == '-') {
44
            if (strcmp(argv[idx], "-p") == 0) {
49
            if (strcmp(argv[idx], "-p") == 0) {
45
                idx++;
50
                idx++;
46
                if (argv[idx] == NULL || argv[idx][0] == '\0') {
51
                if (argv[idx] == NULL || argv[idx][0] == '\0') {
47
                    printf("ERROR missing pty after -p\n");
52
                    err_quit("missing pty after -p\n");
48
                    exit(-1);
49
                }
53
                }
50
                pty = argv[idx];
54
                pty = argv[idx];
51
                nopt += 2;
55
                nopt += 2;
52
            } else if (strcmp(argv[idx], "--env") == 0) {
56
            } else if (strcmp(argv[idx], "--env") == 0) {
53
                idx++;
57
                idx++;
54
                if (argv[idx] == NULL || argv[idx][0] == '\0') {
58
                if (argv[idx] == NULL || argv[idx][0] == '\0') {
55
                    printf("ERROR missing variable=value pair after --env\n");
59
                    err_quit("missing variable=value pair after --env\n");
56
                    exit(-1);
60
                    exit(-1);
57
                }
61
                }
58
62

Return to bug 201733