本文整理汇总了C++中rb_sys_fail函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_sys_fail函数的具体用法?C++ rb_sys_fail怎么用?C++ rb_sys_fail使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_sys_fail函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init_mutex
static void init_mutex()
{
int mutex_init_result = pthread_mutex_init(&mutex, NULL);
if( mutex_init_result != 0 )
{
rb_sys_fail("Failed to allocate mutex");
}
}
示例2: rb_wcat_close
/*
* call-seq:
* cat.close
*
* Close communication with watchcatd.
*/
static VALUE
rb_wcat_close(VALUE self)
{
VALUE sock = rb_iv_get(self, "@sock");
if (cat_close(NUM2INT(sock)) == -1)
rb_sys_fail("cat_close");
return(Qnil);
}
示例3: t_watch_filename
static VALUE t_watch_filename (VALUE self, VALUE fname)
{
try {
return ULONG2NUM(evma_watch_filename(StringValuePtr(fname)));
} catch (std::runtime_error e) {
rb_sys_fail(e.what());
}
}
示例4: console_set_echo
/*
* call-seq:
* io.echo = flag
*
* Enables/disables echo back.
* On some platforms, all combinations of this flags and raw/cooked
* mode may not be valid.
*
* You must require 'io/console' to use this method.
*/
static VALUE
console_set_echo(VALUE io, VALUE f)
{
conmode t;
rb_io_t *fptr;
int fd;
GetOpenFile(io, fptr);
fd = GetReadFD(fptr);
if (!getattr(fd, &t)) rb_sys_fail(0);
if (RTEST(f))
set_echo(&t, NULL);
else
set_noecho(&t, NULL);
if (!setattr(fd, &t)) rb_sys_fail(0);
return io;
}
示例5: t_watch_pid
static VALUE t_watch_pid (VALUE self, VALUE pid)
{
try {
return ULONG2NUM(evma_watch_pid(NUM2INT(pid)));
} catch (std::runtime_error e) {
rb_sys_fail(e.what());
}
}
示例6: proc_setsid
static VALUE proc_setsid(void) {
rb_pid_t pid;
rb_secure(2);
pid = setsid();
if (pid < 0) rb_sys_fail(0);
return PIDT2NUM(pid);
}
示例7: rd_sys_fail
static void rd_sys_fail(const char *msg)
{
if (errno == ECONNRESET) {
errno = 0;
raise_empty_bt(eErrno_ECONNRESET, msg);
}
rb_sys_fail(msg);
}
示例8: io_nonblock_restore
static VALUE
io_nonblock_restore(VALUE arg)
{
int *restore = (int *)arg;
if (fcntl(restore[0], F_SETFL, restore[1]) == -1)
rb_sys_fail(0);
return Qnil;
}
示例9: FORCE_CLOEXEC
static VALUE FORCE_CLOEXEC(VALUE io)
{
int fd = my_fileno(io);
int flags = fcntl(fd, F_SETFD, FD_CLOEXEC);
if (flags == -1)
rb_sys_fail("fcntl(F_SETFD, FD_CLOEXEC)");
return io;
}
示例10: rsock_raise_socket_error
void
rsock_raise_socket_error(const char *reason, int error)
{
#ifdef EAI_SYSTEM
if (error == EAI_SYSTEM) rb_sys_fail(reason);
#endif
rb_raise(rb_eSocket, "%s: %s", reason, gai_strerror(error));
}
示例11: make_fd_nonblock
static void
make_fd_nonblock(int fd)
{
int flags;
#ifdef F_GETFL
flags = fcntl(fd, F_GETFL);
if (flags == -1) {
rb_sys_fail("fnctl(2)");
}
#else
flags = 0;
#endif
flags |= O_NONBLOCK;
if (fcntl(fd, F_SETFL, flags) == -1) {
rb_sys_fail("fnctl(2)");
}
}
示例12: check_usb_error
static int check_usb_error(char *reason, int ret)
{
if (ret < 0) {
errno = -ret;
rb_sys_fail(reason);
}
return ret;
}
示例13: pinkrb_trace_me
/*
* Document-method: PinkTrace::Trace.me
* call-seq:
* PinkTrace::Trace.me() -> nil
*
* Indicates that this process is to be traced by its parent. Any signal
* (except SIGKILL) delivered to this process will cause it to stop and its
* parent to be notified via Process.wait. Also, all subsequent calls to
* execve(2) by this process will cause a SIGTRAP to be sent to it, giving the
* parent a chance to gain control before the new program begins execution.
*
* Note: This function is used only by the child process; the rest are used
* only by the parent.
*/
VALUE
pinkrb_trace_me(VALUE mod)
{
if (!pink_trace_me())
rb_sys_fail("pink_trace_me()");
return Qnil;
}
示例14: cCommand_execute_async
static PGresult* cCommand_execute_async(VALUE self, PGconn *db, VALUE query) {
int socket_fd;
int retval;
fd_set rset;
PGresult *response;
struct timeval start;
char* str = StringValuePtr(query);
while ((response = PQgetResult(db)) != NULL) {
PQclear(response);
}
retval = PQsendQuery(db, str);
if (!retval) {
if(PQstatus(db) != CONNECTION_OK) {
PQreset(db);
if (PQstatus(db) == CONNECTION_OK) {
retval = PQsendQuery(db, str);
} else {
VALUE connection = rb_iv_get(self, "@connection");
full_connect(connection, db);
retval = PQsendQuery(db, str);
}
}
if(!retval) {
rb_raise(eConnectionError, PQerrorMessage(db));
}
}
gettimeofday(&start, NULL);
socket_fd = PQsocket(db);
for(;;) {
FD_ZERO(&rset);
FD_SET(socket_fd, &rset);
retval = rb_thread_select(socket_fd + 1, &rset, NULL, NULL, NULL);
if (retval < 0) {
rb_sys_fail(0);
}
if (retval == 0) {
continue;
}
if (PQconsumeInput(db) == 0) {
rb_raise(eConnectionError, PQerrorMessage(db));
}
if (PQisBusy(db) == 0) {
break;
}
}
data_objects_debug(query, &start);
return PQgetResult(db);
}
示例15: ossl_ssl_read_internal
static VALUE
ossl_ssl_read_internal(int argc, VALUE *argv, VALUE self, int nonblock)
{
SSL *ssl;
int ilen, nread = 0;
VALUE len, str;
rb_io_t *fptr;
rb_scan_args(argc, argv, "11", &len, &str);
ilen = NUM2INT(len);
if(NIL_P(str)) str = rb_str_new(0, ilen);
else{
StringValue(str);
rb_str_modify(str);
rb_str_resize(str, ilen);
}
if(ilen == 0) return str;
Data_Get_Struct(self, SSL, ssl);
GetOpenFile(ossl_ssl_get_io(self), fptr);
if (ssl) {
if(!nonblock && SSL_pending(ssl) <= 0)
rb_thread_wait_fd(FPTR_TO_FD(fptr));
for (;;){
nread = SSL_read(ssl, RSTRING_PTR(str), RSTRING_LEN(str));
switch(ssl_get_error(ssl, nread)){
case SSL_ERROR_NONE:
goto end;
case SSL_ERROR_ZERO_RETURN:
rb_eof_error();
case SSL_ERROR_WANT_WRITE:
write_would_block(nonblock);
rb_io_wait_writable(FPTR_TO_FD(fptr));
continue;
case SSL_ERROR_WANT_READ:
read_would_block(nonblock);
rb_io_wait_readable(FPTR_TO_FD(fptr));
continue;
case SSL_ERROR_SYSCALL:
if(ERR_peek_error() == 0 && nread == 0) rb_eof_error();
rb_sys_fail(0);
default:
ossl_raise(eSSLError, "SSL_read:");
}
}
}
else {
ID meth = nonblock ? rb_intern("read_nonblock") : rb_intern("sysread");
rb_warning("SSL session is not started yet.");
return rb_funcall(ossl_ssl_get_io(self), meth, 2, len, str);
}
end:
rb_str_set_len(str, nread);
OBJ_TAINT(str);
return str;
}