Skip to content

Commit

Permalink
Revert "Merge pull request #169 from Daniel-Abrecht/kill_function_cha…
Browse files Browse the repository at this point in the history
…nge"

This reverts commit 13b1e68, reversing
changes made to 12caa78.
  • Loading branch information
Tyriar committed Jul 20, 2018
1 parent 2c1c0e7 commit 7360eb7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 53 deletions.
35 changes: 0 additions & 35 deletions src/unix/pty.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,6 @@ NAN_METHOD(PtyOpen);
NAN_METHOD(PtyResize);
NAN_METHOD(PtyGetProc);

#if defined(TIOCSIG) || defined(TIOCSIGNAL)
#define DEFINE_PTY_KILL
NAN_METHOD(PtyKill);
#else
#warning "The function PtyKill will be unavailable because the ioctls TIOCSIG and TIOCSIGNAL don't exist"
#endif

/**
* Functions
*/
Expand Down Expand Up @@ -354,29 +347,6 @@ NAN_METHOD(PtyOpen) {
return info.GetReturnValue().Set(obj);
}

#ifdef DEFINE_PTY_KILL
NAN_METHOD(PtyKill) {
Nan::HandleScope scope;

if (info.Length() != 2 ||
!info[0]->IsNumber() ||
!info[1]->IsNumber()) {
return Nan::ThrowError("Usage: pty.kill(fd, signal)");
}

int fd = info[0]->IntegerValue();
int signal = info[1]->IntegerValue();

#if defined(TIOCSIG)
if (ioctl(fd, TIOCSIG, signal) == -1)
return Nan::ThrowError("ioctl(2) failed.");
#elif defined(TIOCSIGNAL)
if (ioctl(fd, TIOCSIGNAL, signal) == -1)
return Nan::ThrowError("ioctl(2) failed.");
#endif
}
#endif

NAN_METHOD(PtyResize) {
Nan::HandleScope scope;

Expand Down Expand Up @@ -736,11 +706,6 @@ NAN_MODULE_INIT(init) {
Nan::Set(target,
Nan::New<v8::String>("open").ToLocalChecked(),
Nan::New<v8::FunctionTemplate>(PtyOpen)->GetFunction());
#ifdef DEFINE_PTY_KILL
Nan::Set(target,
Nan::New<v8::String>("kill").ToLocalChecked(),
Nan::New<v8::FunctionTemplate>(PtyKill)->GetFunction());
#endif
Nan::Set(target,
Nan::New<v8::String>("resize").ToLocalChecked(),
Nan::New<v8::FunctionTemplate>(PtyResize)->GetFunction());
Expand Down
19 changes: 4 additions & 15 deletions src/unixTerminal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import * as net from 'net';
import * as path from 'path';
import * as tty from 'tty';
import * as os from 'os';
import { Terminal, DEFAULT_COLS, DEFAULT_ROWS } from './terminal';
import { IProcessEnv, IPtyForkOptions, IPtyOpenOptions } from './interfaces';
import { ArgvOrCommandLine } from './types';
Expand Down Expand Up @@ -231,20 +230,10 @@ export class UnixTerminal extends Terminal {
this._socket.destroy();
}

public kill(signal: string = 'SIGHUP'): void {
if (signal in os.constants.signals) {
try {
// pty.kill will not be available on systems which don't support
// the TIOCSIG/TIOCSIGNAL ioctl
if (pty.kill && signal !== 'SIGHUP') {
pty.kill(this._fd, os.constants.signals[signal]);
} else {
process.kill(this.pid, signal);
}
} catch (e) { /* swallow */ }
} else {
throw new Error('Unknown signal: ' + signal);
}
public kill(signal?: string): void {
try {
process.kill(this.pid, signal || 'SIGHUP');
} catch (e) { /* swallow */ }
}

/**
Expand Down
5 changes: 2 additions & 3 deletions typings/node-pty.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,9 @@ declare module 'node-pty' {

/**
* Kills the pty.
* @param signal The signal to use, defaults to SIGHUP. If the TIOCSIG/TIOCSIGNAL ioctl is not
* supported then the process will be killed instead. This parameter is not supported on
* @param signal The signal to use, defaults to SIGHUP. This parameter is not supported on
* Windows.
* @throws Will throw when signal is used on Windows.
* @throws Will throw when signal is used on Windows.
*/
kill(signal?: string): void;
}
Expand Down

0 comments on commit 7360eb7

Please sign in to comment.