Sha256: 510c68c6f05e89e1a3ecfdf10b0eb1316a5150aa9de40db29367a1691594e26c

Contents?: true

Size: 361 Bytes

Versions: 1

Compression:

Stored size: 361 Bytes

Contents

#include <ruby.h>
#include <unistd.h>

static VALUE fd_ttyname(VALUE self, VALUE fd)
{
	char * name = ttyname(NUM2INT(fd));

	if (name == NULL)
		rb_raise(rb_eRuntimeError, "not a TTY device");

	return rb_str_new2(name);
}

void Init_ttyname()
{
	VALUE mTTYName = rb_define_module("TTYName");
	rb_define_singleton_method(mTTYName, "ttyname", fd_ttyname, 1);
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ttyname-1.0.0 ext/ttyname.c