rubysl-pty 1.0.0 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -2
- data/ext/rubysl/pty/extconf.rb +2 -1
- data/ext/rubysl/pty/pty.c +216 -156
- data/lib/rubysl/pty/version.rb +1 -1
- data/rubysl-pty.gemspec +3 -1
- metadata +18 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e45c272bab13b32a67ff684e47892397576b895
|
4
|
+
data.tar.gz: 75c93df9034041b5b527c06d782239e93cddb4f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cde05155c951165a7d9631d9f91aa38a7314cc3d77b10d7e3b2faea37814c5a84f1b55b21c52ffde87d35bec55b0e0c4d3ac5dbf711d6730ceb33912f83d139
|
7
|
+
data.tar.gz: 63d5cf4a30dc53bd7c95ea4afdb681374285b6e4909fa2fe6e4373afbfd4c97980f0f999ea29724ff96cdd65c5e0ea9e8412ffc13728dc75340f857ae544bda1
|
data/.travis.yml
CHANGED
data/ext/rubysl/pty/extconf.rb
CHANGED
@@ -5,12 +5,13 @@ if /mswin32|mingw|bccwin32/ !~ RUBY_PLATFORM
|
|
5
5
|
have_header("sys/wait.h")
|
6
6
|
have_func("setresuid")
|
7
7
|
have_header("libutil.h")
|
8
|
+
have_header("unistd.h")
|
8
9
|
have_header("pty.h")
|
9
10
|
have_library("util", "openpty")
|
10
11
|
if have_func("openpty") or
|
11
12
|
have_func("_getpty") or
|
12
13
|
have_func("ptsname") or
|
13
14
|
have_func("ioctl")
|
14
|
-
create_makefile('pty')
|
15
|
+
create_makefile('pty/pty')
|
15
16
|
end
|
16
17
|
end
|
data/ext/rubysl/pty/pty.c
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
#include "config.h"
|
1
|
+
#include "ruby/config.h"
|
2
|
+
#ifdef RUBY_EXTCONF_H
|
3
|
+
#include RUBY_EXTCONF_H
|
4
|
+
#endif
|
5
|
+
#include <stdlib.h>
|
2
6
|
#include <stdio.h>
|
3
7
|
#include <sys/types.h>
|
4
8
|
#include <sys/stat.h>
|
@@ -12,19 +16,24 @@
|
|
12
16
|
#ifdef HAVE_LIBUTIL_H
|
13
17
|
#include <libutil.h>
|
14
18
|
#endif
|
19
|
+
#ifdef HAVE_UTIL_H
|
20
|
+
#include <util.h>
|
21
|
+
#endif
|
15
22
|
#ifdef HAVE_PTY_H
|
16
23
|
#include <pty.h>
|
17
24
|
#endif
|
18
25
|
#ifdef HAVE_SYS_WAIT_H
|
19
26
|
#include <sys/wait.h>
|
20
27
|
#else
|
28
|
+
#ifndef WIFSTOPPED
|
21
29
|
#define WIFSTOPPED(status) (((status) & 0xff) == 0x7f)
|
22
30
|
#endif
|
31
|
+
#endif
|
23
32
|
#include <ctype.h>
|
24
33
|
|
25
|
-
#include "ruby.h"
|
26
|
-
#include "
|
27
|
-
#include "util.h"
|
34
|
+
#include "ruby/ruby.h"
|
35
|
+
#include "ruby/io.h"
|
36
|
+
#include "ruby/util.h"
|
28
37
|
|
29
38
|
#include <signal.h>
|
30
39
|
#ifdef HAVE_SYS_STROPTS_H
|
@@ -35,14 +44,32 @@
|
|
35
44
|
#include <unistd.h>
|
36
45
|
#endif
|
37
46
|
|
47
|
+
#if defined(HAVE_OPENPTY) && !defined(HAVE_PTY_H)
|
48
|
+
/* Normally, the following header would be used:
|
49
|
+
* #include <util.h>
|
50
|
+
*
|
51
|
+
* but MRI has an include file "util.h" which may be picked up depending on the
|
52
|
+
* order of include directories. Rather than futz with that, we just add the
|
53
|
+
* prototype.
|
54
|
+
*/
|
55
|
+
#include <sys/termios.h>
|
56
|
+
|
57
|
+
int openpty(int *amaster, int *aslave, char *name, struct termios *termp,
|
58
|
+
struct winsize *winp);
|
59
|
+
#endif
|
60
|
+
|
61
|
+
#ifdef TIOCSCTTY
|
62
|
+
#include <sys/ioctl.h>
|
63
|
+
#endif
|
64
|
+
|
38
65
|
#define DEVICELEN 16
|
39
66
|
|
40
67
|
#if !defined(HAVE_OPENPTY)
|
41
68
|
#if defined(__hpux)
|
42
69
|
static const
|
43
|
-
char
|
44
|
-
|
45
|
-
|
70
|
+
char MasterDevice[] = "/dev/ptym/pty%s",
|
71
|
+
SlaveDevice[] = "/dev/pty/tty%s",
|
72
|
+
*const deviceNo[] = {
|
46
73
|
"p0","p1","p2","p3","p4","p5","p6","p7",
|
47
74
|
"p8","p9","pa","pb","pc","pd","pe","pf",
|
48
75
|
"q0","q1","q2","q3","q4","q5","q6","q7",
|
@@ -63,9 +90,9 @@ char MasterDevice[] = "/dev/ptym/pty%s",
|
|
63
90
|
};
|
64
91
|
#elif defined(_IBMESA) /* AIX/ESA */
|
65
92
|
static const
|
66
|
-
char
|
67
|
-
|
68
|
-
|
93
|
+
char MasterDevice[] = "/dev/ptyp%s",
|
94
|
+
SlaveDevice[] = "/dev/ttyp%s",
|
95
|
+
*const deviceNo[] = {
|
69
96
|
"00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f",
|
70
97
|
"10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f",
|
71
98
|
"20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f",
|
@@ -85,9 +112,9 @@ char MasterDevice[] = "/dev/ptyp%s",
|
|
85
112
|
};
|
86
113
|
#elif !defined(HAVE_PTSNAME)
|
87
114
|
static const
|
88
|
-
char
|
89
|
-
|
90
|
-
|
115
|
+
char MasterDevice[] = "/dev/pty%s",
|
116
|
+
SlaveDevice[] = "/dev/tty%s",
|
117
|
+
*const deviceNo[] = {
|
91
118
|
"p0","p1","p2","p3","p4","p5","p6","p7",
|
92
119
|
"p8","p9","pa","pb","pc","pd","pe","pf",
|
93
120
|
"q0","q1","q2","q3","q4","q5","q6","q7",
|
@@ -115,9 +142,11 @@ char MasterDevice[] = "/dev/pty%s",
|
|
115
142
|
|
116
143
|
static VALUE eChildExited;
|
117
144
|
|
145
|
+
/* Returns the exit status of the child for which PTY#check
|
146
|
+
* raised this exception
|
147
|
+
*/
|
118
148
|
static VALUE
|
119
|
-
echild_status(self)
|
120
|
-
VALUE self;
|
149
|
+
echild_status(VALUE self)
|
121
150
|
{
|
122
151
|
return rb_ivar_get(self, rb_intern("status"));
|
123
152
|
}
|
@@ -128,51 +157,7 @@ struct pty_info {
|
|
128
157
|
VALUE thread;
|
129
158
|
};
|
130
159
|
|
131
|
-
static void
|
132
|
-
raise_from_wait(state, info)
|
133
|
-
struct pty_info *info;
|
134
|
-
char *state;
|
135
|
-
{
|
136
|
-
VALUE last_status = rb_gv_get("$?");
|
137
|
-
char buf[1024];
|
138
|
-
VALUE exc;
|
139
|
-
|
140
|
-
snprintf(buf, sizeof(buf), "pty - %s: %ld", state, (long)info->child_pid);
|
141
|
-
exc = rb_exc_new2(eChildExited, buf);
|
142
|
-
rb_iv_set(exc, "status", last_status);
|
143
|
-
rb_funcall(info->thread, rb_intern("raise"), 1, exc);
|
144
|
-
}
|
145
|
-
|
146
|
-
static VALUE
|
147
|
-
pty_syswait(info)
|
148
|
-
struct pty_info *info;
|
149
|
-
{
|
150
|
-
int cpid, status;
|
151
|
-
|
152
|
-
for (;;) {
|
153
|
-
cpid = rb_waitpid(info->child_pid, &status, WUNTRACED);
|
154
|
-
if (cpid == -1) return Qnil;
|
155
|
-
|
156
|
-
#if defined(WIFSTOPPED)
|
157
|
-
#elif defined(IF_STOPPED)
|
158
|
-
#define WIFSTOPPED(status) IF_STOPPED(status)
|
159
|
-
#else
|
160
|
-
---->> Either IF_STOPPED or WIFSTOPPED is needed <<----
|
161
|
-
#endif /* WIFSTOPPED | IF_STOPPED */
|
162
|
-
if (WIFSTOPPED(status)) { /* suspend */
|
163
|
-
raise_from_wait("stopped", info);
|
164
|
-
}
|
165
|
-
else if (kill(info->child_pid, 0) == 0) {
|
166
|
-
raise_from_wait("changed", info);
|
167
|
-
}
|
168
|
-
else {
|
169
|
-
raise_from_wait("exited", info);
|
170
|
-
return Qnil;
|
171
|
-
}
|
172
|
-
}
|
173
|
-
}
|
174
|
-
|
175
|
-
static void getDevice _((int*, int*, char [DEVICELEN]));
|
160
|
+
static void getDevice _((int*, int*, char [DEVICELEN], int));
|
176
161
|
|
177
162
|
struct exec_info {
|
178
163
|
int argc;
|
@@ -191,11 +176,8 @@ pty_exec(v)
|
|
191
176
|
}
|
192
177
|
|
193
178
|
static void
|
194
|
-
establishShell(argc, argv, info,
|
195
|
-
|
196
|
-
VALUE *argv;
|
197
|
-
struct pty_info *info;
|
198
|
-
char SlaveName[DEVICELEN];
|
179
|
+
establishShell(int argc, VALUE *argv, struct pty_info *info,
|
180
|
+
char SlaveName[DEVICELEN])
|
199
181
|
{
|
200
182
|
int i, master, slave;
|
201
183
|
char *p, tmp, *getenv();
|
@@ -221,7 +203,7 @@ establishShell(argc, argv, info, SlaveName)
|
|
221
203
|
argc = 1;
|
222
204
|
argv = &v;
|
223
205
|
}
|
224
|
-
getDevice(&master, &slave, SlaveName);
|
206
|
+
getDevice(&master, &slave, SlaveName, 0);
|
225
207
|
|
226
208
|
info->thread = rb_thread_current();
|
227
209
|
VALUE child_pid = rb_funcall(rb_mKernel, rb_intern("fork"), 0);
|
@@ -297,115 +279,202 @@ establishShell(argc, argv, info, SlaveName)
|
|
297
279
|
}
|
298
280
|
|
299
281
|
static int
|
300
|
-
|
301
|
-
int *master, *slave, fail;
|
302
|
-
char SlaveName[DEVICELEN];
|
282
|
+
no_mesg(char *slavedevice, int nomesg)
|
303
283
|
{
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
284
|
+
if (nomesg) {
|
285
|
+
return chmod(slavedevice, 0600);
|
286
|
+
} else {
|
287
|
+
return 0;
|
288
|
+
}
|
289
|
+
}
|
290
|
+
|
291
|
+
static int
|
292
|
+
get_device_once(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg, int fail)
|
293
|
+
{
|
294
|
+
#if defined(HAVE_POSIX_OPENPT)
|
295
|
+
int masterfd = -1, slavefd = -1;
|
296
|
+
char *slavedevice;
|
297
|
+
struct sigaction dfl, old;
|
298
|
+
|
299
|
+
dfl.sa_handler = SIG_DFL;
|
300
|
+
dfl.sa_flags = 0;
|
301
|
+
sigemptyset(&dfl.sa_mask);
|
302
|
+
|
303
|
+
if ((masterfd = posix_openpt(O_RDWR|O_NOCTTY)) == -1) goto error;
|
304
|
+
if (sigaction(SIGCHLD, &dfl, &old) == -1) goto error;
|
305
|
+
if (grantpt(masterfd) == -1) goto grantpt_error;
|
306
|
+
if (sigaction(SIGCHLD, &old, NULL) == -1) goto error;
|
307
|
+
if (unlockpt(masterfd) == -1) goto error;
|
308
|
+
if ((slavedevice = ptsname(masterfd)) == NULL) goto error;
|
309
|
+
if (no_mesg(slavedevice, nomesg) == -1) goto error;
|
310
|
+
if ((slavefd = open(slavedevice, O_RDWR|O_NOCTTY, 0)) == -1) goto error;
|
311
|
+
|
312
|
+
#if defined I_PUSH && !defined linux
|
313
|
+
if (ioctl(slavefd, I_PUSH, "ptem") == -1) goto error;
|
314
|
+
if (ioctl(slavefd, I_PUSH, "ldterm") == -1) goto error;
|
315
|
+
if (ioctl(slavefd, I_PUSH, "ttcompat") == -1) goto error;
|
316
|
+
#endif
|
317
|
+
|
318
|
+
*master = masterfd;
|
319
|
+
*slave = slavefd;
|
320
|
+
strlcpy(SlaveName, slavedevice, DEVICELEN);
|
321
|
+
return 0;
|
322
|
+
|
323
|
+
grantpt_error:
|
324
|
+
sigaction(SIGCHLD, &old, NULL);
|
325
|
+
error:
|
326
|
+
if (slavefd != -1) close(slavefd);
|
327
|
+
if (masterfd != -1) close(masterfd);
|
328
|
+
if (fail) {
|
329
|
+
rb_raise(rb_eRuntimeError, "can't get Master/Slave device");
|
330
|
+
}
|
331
|
+
return -1;
|
332
|
+
#elif defined HAVE_OPENPTY
|
333
|
+
/*
|
334
|
+
* Use openpty(3) of 4.3BSD Reno and later,
|
335
|
+
* or the same interface function.
|
336
|
+
*/
|
309
337
|
if (openpty(master, slave, SlaveName,
|
310
|
-
|
338
|
+
(struct termios *)0, (struct winsize *)0) == -1) {
|
339
|
+
if (!fail) return -1;
|
340
|
+
rb_raise(rb_eRuntimeError, "openpty() failed");
|
341
|
+
}
|
342
|
+
if (no_mesg(SlaveName, nomesg) == -1) {
|
311
343
|
if (!fail) return -1;
|
312
|
-
rb_raise(rb_eRuntimeError, "
|
344
|
+
rb_raise(rb_eRuntimeError, "can't chmod slave pty");
|
313
345
|
}
|
314
346
|
|
315
347
|
return 0;
|
348
|
+
|
316
349
|
#elif defined HAVE__GETPTY
|
317
350
|
char *name;
|
351
|
+
mode_t mode = nomesg ? 0600 : 0622;
|
318
352
|
|
319
|
-
if (!(name = _getpty(master, O_RDWR,
|
353
|
+
if (!(name = _getpty(master, O_RDWR, mode, 0))) {
|
320
354
|
if (!fail) return -1;
|
321
355
|
rb_raise(rb_eRuntimeError, "_getpty() failed");
|
322
356
|
}
|
323
357
|
|
324
358
|
*slave = open(name, O_RDWR);
|
325
|
-
|
359
|
+
/* error check? */
|
360
|
+
strlcpy(SlaveName, name, DEVICELEN);
|
326
361
|
|
327
362
|
return 0;
|
328
|
-
#
|
329
|
-
int
|
330
|
-
|
331
|
-
#ifdef HAVE_PTSNAME
|
332
|
-
char *pn;
|
363
|
+
#elif defined(HAVE_PTSNAME)
|
364
|
+
int masterfd = -1, slavefd = -1;
|
365
|
+
char *slavedevice;
|
333
366
|
void (*s)();
|
334
367
|
|
335
368
|
extern char *ptsname(int);
|
336
369
|
extern int unlockpt(int);
|
337
370
|
extern int grantpt(int);
|
338
371
|
|
339
|
-
if((
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
if(ioctl(j, I_PUSH, "ptem") != -1) {
|
348
|
-
if(ioctl(j, I_PUSH, "ldterm") != -1) {
|
349
|
-
ioctl(j, I_PUSH, "ttcompat");
|
350
|
-
#endif
|
351
|
-
*master = i;
|
352
|
-
*slave = j;
|
353
|
-
strncpy(SlaveName, pn, sizeof SlaveName);
|
354
|
-
return 0;
|
372
|
+
if((masterfd = open("/dev/ptmx", O_RDWR, 0)) == -1) goto error;
|
373
|
+
s = signal(SIGCHLD, SIG_DFL);
|
374
|
+
if(grantpt(masterfd) == -1) goto error;
|
375
|
+
signal(SIGCHLD, s);
|
376
|
+
if(unlockpt(masterfd) == -1) goto error;
|
377
|
+
if((slavedevice = ptsname(masterfd)) == NULL) goto error;
|
378
|
+
if (no_mesg(slavedevice, nomesg) == -1) goto error;
|
379
|
+
if((slavefd = open(slavedevice, O_RDWR, 0)) == -1) goto error;
|
355
380
|
#if defined I_PUSH && !defined linux
|
356
|
-
|
357
|
-
|
381
|
+
if(ioctl(slavefd, I_PUSH, "ptem") == -1) goto error;
|
382
|
+
if(ioctl(slavefd, I_PUSH, "ldterm") == -1) goto error;
|
383
|
+
ioctl(slavefd, I_PUSH, "ttcompat");
|
358
384
|
#endif
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
if (
|
385
|
+
*master = masterfd;
|
386
|
+
*slave = slavefd;
|
387
|
+
strlcpy(SlaveName, slavedevice, DEVICELEN);
|
388
|
+
return 0;
|
389
|
+
|
390
|
+
error:
|
391
|
+
if (slavefd != -1) close(slavefd);
|
392
|
+
if (masterfd != -1) close(masterfd);
|
393
|
+
if (fail) rb_raise(rb_eRuntimeError, "can't get Master/Slave device");
|
366
394
|
return -1;
|
367
395
|
#else
|
368
|
-
|
396
|
+
int masterfd = -1, slavefd = -1;
|
397
|
+
const char *const *p;
|
369
398
|
char MasterName[DEVICELEN];
|
370
399
|
|
371
400
|
for (p = deviceNo; *p != NULL; p++) {
|
372
401
|
snprintf(MasterName, sizeof MasterName, MasterDevice, *p);
|
373
|
-
if ((
|
374
|
-
*master =
|
375
|
-
snprintf(SlaveName,
|
376
|
-
if ((
|
377
|
-
*slave =
|
378
|
-
chown(SlaveName, getuid(), getgid());
|
379
|
-
chmod(SlaveName, 0622);
|
402
|
+
if ((masterfd = open(MasterName,O_RDWR,0)) >= 0) {
|
403
|
+
*master = masterfd;
|
404
|
+
snprintf(SlaveName, DEVICELEN, SlaveDevice, *p);
|
405
|
+
if ((slavefd = open(SlaveName,O_RDWR,0)) >= 0) {
|
406
|
+
*slave = slavefd;
|
407
|
+
if (chown(SlaveName, getuid(), getgid()) != 0) goto error;
|
408
|
+
if (chmod(SlaveName, nomesg ? 0600 : 0622) != 0) goto error;
|
380
409
|
return 0;
|
381
410
|
}
|
382
|
-
close(
|
411
|
+
close(masterfd);
|
383
412
|
}
|
384
413
|
}
|
414
|
+
error:
|
415
|
+
if (slavefd != -1) close(slavefd);
|
416
|
+
if (masterfd != -1) close(masterfd);
|
385
417
|
if (fail) rb_raise(rb_eRuntimeError, "can't get %s", SlaveName);
|
386
418
|
return -1;
|
387
419
|
#endif
|
388
|
-
#endif
|
389
420
|
}
|
390
421
|
|
391
422
|
static void
|
392
|
-
getDevice(master, slave,
|
393
|
-
int *master, *slave;
|
394
|
-
char slavename[DEVICELEN];
|
423
|
+
getDevice(int *master, int *slave, char SlaveName[DEVICELEN], int nomesg)
|
395
424
|
{
|
396
|
-
if (get_device_once(master, slave,
|
397
|
-
|
398
|
-
get_device_once(master, slave, slavename, 1);
|
425
|
+
if (get_device_once(master, slave, SlaveName, nomesg, 0)) {
|
426
|
+
get_device_once(master, slave, SlaveName, nomesg, 1);
|
399
427
|
}
|
400
428
|
}
|
401
429
|
|
402
|
-
/* ruby function: getpty */
|
403
430
|
static VALUE
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
431
|
+
pty_get_device(VALUE klass)
|
432
|
+
{
|
433
|
+
int master_fd, slave_fd;
|
434
|
+
char slavename[DEVICELEN];
|
435
|
+
VALUE ary;
|
436
|
+
|
437
|
+
getDevice(&master_fd, &slave_fd, slavename, 1);
|
438
|
+
ary = rb_ary_new3(3, INT2NUM(master_fd), INT2NUM(slave_fd),
|
439
|
+
rb_str_new_cstr(slavename));
|
440
|
+
return ary;
|
441
|
+
}
|
442
|
+
|
443
|
+
/*
|
444
|
+
* call-seq:
|
445
|
+
* PTY.spawn(command_line) { |r, w, pid| ... }
|
446
|
+
* PTY.spawn(command_line) => [r, w, pid]
|
447
|
+
* PTY.spawn(command, args, ...) { |r, w, pid| ... }
|
448
|
+
* PTY.spawn(command, args, ...) => [r, w, pid]
|
449
|
+
* PTY.getpty(command_line) { |r, w, pid| ... }
|
450
|
+
* PTY.getpty(command_line) => [r, w, pid]
|
451
|
+
* PTY.getpty(command, args, ...) { |r, w, pid| ... }
|
452
|
+
* PTY.getpty(command, args, ...) => [r, w, pid]
|
453
|
+
*
|
454
|
+
* Spawns the specified command on a newly allocated pty.
|
455
|
+
*
|
456
|
+
* The command's controlling tty is set to the slave device of the pty
|
457
|
+
* and its standard input/output/error is redirected to the slave device.
|
458
|
+
*
|
459
|
+
* <tt>command_line</tt>:: The full command line to run
|
460
|
+
* <tt>command</tt>:: The command to run, as a String.
|
461
|
+
* <tt>args</tt>:: Zero or more arguments, as Strings, representing
|
462
|
+
* the arguments to +command+
|
463
|
+
*
|
464
|
+
* In the non-block form this returns an array of size three,
|
465
|
+
* <tt>[r, w, pid]</tt>. In the block form the block will be called with
|
466
|
+
* these as arguments, <tt>|r,w,pid|</tt>:
|
467
|
+
*
|
468
|
+
* +r+:: An IO that can be read from that contains the command's
|
469
|
+
* standard output and standard error
|
470
|
+
* +w+:: An IO that can be written to that is the command's
|
471
|
+
* standard input
|
472
|
+
* +pid+:: The process identifier for the command.
|
473
|
+
*/
|
474
|
+
static VALUE
|
475
|
+
pty_getpty(int argc, VALUE *argv, VALUE self)
|
408
476
|
{
|
477
|
+
|
409
478
|
VALUE res, rport, wport;
|
410
479
|
struct pty_info info;
|
411
480
|
struct pty_info thinfo;
|
@@ -425,10 +494,7 @@ pty_getpty(argc, argv, self)
|
|
425
494
|
rb_ivar_set(wport, rb_intern("@path"), rb_str_new2(SlaveName));
|
426
495
|
rb_funcall(wport, rb_intern("sync="), 1, Qtrue);
|
427
496
|
|
428
|
-
res =
|
429
|
-
rb_ary_store(res,0,(VALUE)rport);
|
430
|
-
rb_ary_store(res,1,(VALUE)wport);
|
431
|
-
rb_ary_store(res,2,INT2FIX(info.child_pid));
|
497
|
+
res = rb_ary_new3(3, (VALUE)rport, (VALUE)wport, INT2FIX(info.child_pid));
|
432
498
|
|
433
499
|
if (rb_block_given_p()) {
|
434
500
|
rb_yield(res);
|
@@ -437,34 +503,28 @@ pty_getpty(argc, argv, self)
|
|
437
503
|
return res;
|
438
504
|
}
|
439
505
|
|
440
|
-
/*
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
rb_yield(Qnil);
|
447
|
-
return self;
|
448
|
-
}
|
506
|
+
/*
|
507
|
+
* Document-class: PTY::ChildExited
|
508
|
+
*
|
509
|
+
* Thrown when PTY#check is called for a pid that represents a process that
|
510
|
+
* has exited.
|
511
|
+
*/
|
449
512
|
|
450
|
-
/*
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
return self;
|
457
|
-
}
|
513
|
+
/*
|
514
|
+
* Document-class: PTY
|
515
|
+
*
|
516
|
+
* Creates and managed pseudo terminals (PTYs). See also
|
517
|
+
* http://en.wikipedia.org/wiki/Pseudo_terminal
|
518
|
+
*/
|
458
519
|
|
459
520
|
void
|
460
521
|
Init_pty()
|
461
522
|
{
|
462
523
|
VALUE cPTY = rb_define_module("PTY");
|
463
|
-
rb_define_module_function(cPTY,"getpty",pty_getpty
|
464
|
-
rb_define_module_function(cPTY,"spawn",pty_getpty
|
465
|
-
|
466
|
-
rb_define_module_function(cPTY,"reset_signal",pty_reset_signal,0);
|
524
|
+
rb_define_module_function(cPTY, "getpty", pty_getpty, -1);
|
525
|
+
rb_define_module_function(cPTY, "spawn", pty_getpty, -1);
|
526
|
+
rb_define_singleton_method(cPTY, "__get_device__", pty_get_device, 0);
|
467
527
|
|
468
|
-
eChildExited = rb_define_class_under(cPTY,"ChildExited",rb_eRuntimeError);
|
469
|
-
rb_define_method(eChildExited,"status",echild_status,0);
|
528
|
+
eChildExited = rb_define_class_under(cPTY, "ChildExited", rb_eRuntimeError);
|
529
|
+
rb_define_method(eChildExited, "status", echild_status, 0);
|
470
530
|
}
|
data/lib/rubysl/pty/version.rb
CHANGED
data/rubysl-pty.gemspec
CHANGED
@@ -17,8 +17,10 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
+
spec.required_ruby_version = "~> 2.0"
|
21
|
+
|
20
22
|
spec.add_development_dependency "bundler", "~> 1.3"
|
21
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
22
24
|
spec.add_development_dependency "mspec", "~> 1.5"
|
23
|
-
spec.add_development_dependency "rubysl-prettyprint", "~>
|
25
|
+
spec.add_development_dependency "rubysl-prettyprint", "~> 2.0"
|
24
26
|
end
|
metadata
CHANGED
@@ -1,71 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubysl-pty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Shirai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.3'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: mspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '1.5'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.5'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rubysl-prettyprint
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '2.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '2.0'
|
69
69
|
description: Ruby standard library pty.
|
70
70
|
email:
|
71
71
|
- brixen@gmail.com
|
@@ -74,8 +74,8 @@ extensions:
|
|
74
74
|
- ext/rubysl/pty/extconf.rb
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
|
-
- .gitignore
|
78
|
-
- .travis.yml
|
77
|
+
- ".gitignore"
|
78
|
+
- ".travis.yml"
|
79
79
|
- Gemfile
|
80
80
|
- LICENSE
|
81
81
|
- README.md
|
@@ -96,12 +96,12 @@ require_paths:
|
|
96
96
|
- lib
|
97
97
|
required_ruby_version: !ruby/object:Gem::Requirement
|
98
98
|
requirements:
|
99
|
-
- -
|
99
|
+
- - "~>"
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: '0'
|
101
|
+
version: '2.0'
|
102
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
103
|
requirements:
|
104
|
-
- -
|
104
|
+
- - ">="
|
105
105
|
- !ruby/object:Gem::Version
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|
@@ -111,3 +111,4 @@ signing_key:
|
|
111
111
|
specification_version: 4
|
112
112
|
summary: Ruby standard library pty.
|
113
113
|
test_files: []
|
114
|
+
has_rdoc:
|