Giter Club home page Giter Club logo

pty4j's Introduction

Pty4J - Pseudo terminal(PTY) implementation in Java.

official JetBrains project

Build Status

This is a Java implementation of PTY. Written in JNA with native code to make fork of a process.

It is based on two projects that provide the same functionality: JPty and elt.

While JPty is pretty good and written using only JNA it suffers from a hang on Mac OS X when Java is under debug (jawi/JPty#2), because fork doesn't work well in java.

elt works ok, but it has mostly native code(using JNI).

So this one is a mix of the other two: a port of elt to JNA in the style it is made in JPty with only fork and process exec written in native.

Also pty4j implements java interface for pty for windows, using WinPty library.

Dependencies

This library depends on JTermios, part of the PureJavaComm library found at https://github.com/nyholku/purejavacomm. Pty4j depends on the forked version of PureJavaComm (org.jetbrains.pty4j:purejavacomm).

Windows pty implementation used here is the magnificent WinPty library written by Ryan Prichard: https://github.com/rprichard/winpty

Adding Pty4J to your build

The releases are published to Maven Central: org.jetbrains.pty4j:pty4j.

Maven

<dependency>
  <groupId>org.jetbrains.pty4j</groupId>
  <artifactId>pty4j</artifactId>
  <version>0.12.5</version>
</dependency>

Gradle

dependencies {
  implementation 'org.jetbrains.pty4j:pty4j:0.12.5'
}

Usage

Using this library is relatively easy:

String[] cmd = { "/bin/sh", "-l" };
Map<String, String> env = new HashMap<>(System.getenv());
env.put("TERM", "xterm");
PtyProcess process = new PtyProcessBuilder().setCommand(cmd).setEnvironment(env).start();

OutputStream os = process.getOutputStream();
InputStream is = process.getInputStream();

// ... work with the streams ...

// wait until the PTY child process is terminated
int result = process.waitFor();

The operating systems currently supported by pty4j are: Linux, OSX, Windows and FreeBSD.

License

The code in this library is licensed under Eclipse Public License, version 1.0 and can be found online at: http://www.eclipse.org/legal/epl-v10.html.

pty4j's People

Contributors

segrey avatar trofimander avatar stigger avatar rprichard avatar fornever avatar pchel- avatar vladrassokhin avatar andreyakinshin avatar dmpanov avatar cheungxi avatar satsen avatar rhwood avatar fkistner avatar nd avatar yole avatar jackbentley avatar samwot avatar shawnanastasio avatar epeshk avatar gaudima avatar turbanoff avatar wangling12 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.