本文整理汇总了C++中rb_sys_fail函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_sys_fail函数的具体用法?C++ rb_sys_fail怎么用?C++ rb_sys_fail使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rb_sys_fail函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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");
}
}
开发者ID:elektronaut,项目名称:livecode,代码行数:8,代码来源:coremidi.c
示例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);
}
开发者ID:andrenth,项目名称:ruby-watchcat,代码行数:14,代码来源:watchcat.c
示例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());
}
}
开发者ID:bernd,项目名称:eventmachine,代码行数:8,代码来源:rubymain.cpp
示例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;
}
开发者ID:anjali009,项目名称:rails_idea-,代码行数:27,代码来源:console.c
示例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());
}
}
开发者ID:bernd,项目名称:eventmachine,代码行数:8,代码来源:rubymain.cpp
示例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);
}
开发者ID:josacar,项目名称:writing-daemons-in-ruby,代码行数:8,代码来源:proc_setsid.c
示例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);
}
开发者ID:simplegeo,项目名称:kgio,代码行数:8,代码来源:read_write.c
示例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;
}
开发者ID:Danylyuk,项目名称:first_app,代码行数:8,代码来源:nonblock.c
示例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;
}
开发者ID:Daraexus,项目名称:SimuladorCloud,代码行数:8,代码来源:linux_inet_diag.c
示例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));
}
开发者ID:DashYang,项目名称:sim,代码行数:8,代码来源:init.c
示例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)");
}
}
开发者ID:DashYang,项目名称:sim,代码行数:17,代码来源:init.c
示例12: check_usb_error
static int check_usb_error(char *reason, int ret)
{
if (ret < 0) {
errno = -ret;
rb_sys_fail(reason);
}
return ret;
}
开发者ID:atoulme,项目名称:ruby-usb,代码行数:8,代码来源:usb.c
示例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;
}
开发者ID:michaelgruenewald,项目名称:pinktrace,代码行数:22,代码来源:trace.c
示例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);
}
开发者ID:matthewd,项目名称:do,代码行数:58,代码来源:do_postgres_ext.c
示例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;
}
开发者ID:2220142,项目名称:ruby,代码行数:58,代码来源:ossl_ssl.c
示例16: install_at_exit_handler
static void install_at_exit_handler()
{
// Poor Ruby programmers destructor
if( atexit(free_objects) != 0 )
{
free_objects();
rb_sys_fail("Failed to register atexit function");
}
}
开发者ID:jimm,项目名称:rbcoremidi,代码行数:9,代码来源:rbcoremidi.c
示例17: s_unlink
/*
* call-seq:
* POSIX_MQ.unlink(name) => 1
*
* Unlinks the message queue given by +name+. The queue will be destroyed
* when the last process with the queue open closes its queue descriptors.
*/
static VALUE s_unlink(VALUE self, VALUE name)
{
int rv = mq_unlink(StringValueCStr(name));
if (rv < 0)
rb_sys_fail("mq_unlink");
return INT2NUM(1);
}
开发者ID:tmm1,项目名称:ruby_posix_mq,代码行数:16,代码来源:posix_mq.c
示例18: dir_s_rmdir
/*
* call-seq:
* Dir.delete( string ) => 0
* Dir.rmdir( string ) => 0
* Dir.unlink( string ) => 0
*
* Deletes the named directory. Raises a subclass of
* <code>SystemCallError</code> if the directory isn't empty.
*/
static VALUE
dir_s_rmdir(VALUE obj, VALUE dir)
{
check_dirname(&dir);
if (rmdir(RSTRING_PTR(dir)) < 0)
rb_sys_fail(RSTRING_PTR(dir));
return INT2FIX(0);
}
开发者ID:tflynn,项目名称:ruby19-norubygems,代码行数:18,代码来源:dir.c
示例19: init_midi_data
static void init_midi_data()
{
midi_data = CFArrayCreateMutable(kCFAllocatorDefault, 0, NULL);
if( midi_data == NULL )
{
free_objects();
rb_sys_fail("Failed to allocate CFMutableArray");
}
}
开发者ID:elektronaut,项目名称:livecode,代码行数:9,代码来源:coremidi.c
示例20: native_cond_timeout
static struct timespec
native_cond_timeout(rb_nativethread_cond_t *cond, struct timespec timeout_rel)
{
int ret;
struct timeval tv;
struct timespec timeout;
struct timespec now;
#if USE_MONOTONIC_COND
if (cond->clockid == CLOCK_MONOTONIC) {
ret = clock_gettime(cond->clockid, &now);
if (ret != 0)
rb_sys_fail("clock_gettime()");
goto out;
}
if (cond->clockid != CLOCK_REALTIME)
rb_bug("unsupported clockid %"PRIdVALUE, (SIGNED_VALUE)cond->clockid);
#endif
ret = gettimeofday(&tv, 0);
if (ret != 0)
rb_sys_fail(0);
now.tv_sec = tv.tv_sec;
now.tv_nsec = tv.tv_usec * 1000;
#if USE_MONOTONIC_COND
out:
#endif
timeout.tv_sec = now.tv_sec;
timeout.tv_nsec = now.tv_nsec;
timeout.tv_sec += timeout_rel.tv_sec;
timeout.tv_nsec += timeout_rel.tv_nsec;
if (timeout.tv_nsec >= 1000*1000*1000) {
timeout.tv_sec++;
timeout.tv_nsec -= 1000*1000*1000;
}
if (timeout.tv_sec < now.tv_sec)
timeout.tv_sec = TIMET_MAX;
return timeout;
}
开发者ID:mathewv,项目名称:ruby-oneshot,代码行数:44,代码来源:thread_pthread.c
注:本文中的rb_sys_fail函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论