/* plugin.cc * Test sample plugin module for babylond. */ #include "ctrlfd.h" #include #include #include extern "C" { int babylond_plugin_init(ctrlfd_t *cfd, void *dl_handle) { int ret, pid; struct rlimit rlim; cfd->printf("Version 1.0!\n"); ret = getrlimit(RLIMIT_CORE, &rlim); if (ret) { cfd->printf("getrlimit failed: %s\n", strerror(errno)); cfd->done(0); return 1; } else cfd->printf("getrlimit okay!\n"); pid = fork(); if (!pid) { rlim.rlim_cur = RLIM_INFINITY; ret = setrlimit(RLIMIT_CORE, &rlim); if (ret) { cfd->printf("setrlimit failed: %s\n", strerror(errno)); cfd->done(0); _exit(1); } cfd->printf("setrlimit: success!\n"); *(char *)0 = 0; _exit(1); } if (pid < 0) cfd->printf("fork() failed: %s\n", strerror(errno)); cfd->printf("Hello world from plugin! pid = %d\n", pid); cfd->done(0); return 1; } }