https://github.com/federicotdn/crpty
Call forkpty(3) from Crystal code
https://github.com/federicotdn/crpty
c crystal forkpty openpty pseudoterminal pty terminal tty
Last synced: 5 months ago
JSON representation
Call forkpty(3) from Crystal code
- Host: GitHub
- URL: https://github.com/federicotdn/crpty
- Owner: federicotdn
- License: mit
- Created: 2021-08-04T22:17:59.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-08-04T22:26:57.000Z (over 4 years ago)
- Last Synced: 2025-03-06T12:52:07.454Z (about 1 year ago)
- Topics: c, crystal, forkpty, openpty, pseudoterminal, pty, terminal, tty
- Language: Crystal
- Homepage:
- Size: 1.95 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# crpty
Use [`forkpty(3)`](https://linux.die.net/man/3/forkpty) from Crystal.
Note: this library is only an experiment/learning project for now. Only tested on Ubuntu 20.04 LTS 64-bit. Requires `gcc` to compile.
## Installation
1. Add the dependency to your `shard.yml`:
```yaml
dependencies:
crpty:
github: federicotdn/crpty
```
2. Run `shards install`
## Usage
```crystal
require "crpty"
result = CrPty.fork_pty()
if result.pid == 0
# Child process!
# Do something like e.g. exec() to Bash
else
# Parent process!
# `result.master_fd` points to the master side of the pseudoterminal
master_fd = IO::FileDescriptor.new result.master_fd
# e.g. Copy bytes from STDIN to master_fd and from master_fd to STDOUT
end
```
## Contributing
1. Fork it ()
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
## Contributors
- [federicotdn](https://github.com/federicotdn) - creator and maintainer