TEST(spawn, posix_spawnattr_setsigmask_posix_spawnattr_getsigmask) { posix_spawnattr_t sa; ASSERT_EQ(0, posix_spawnattr_init(&sa)); sigset_t sigs; ASSERT_EQ(0, posix_spawnattr_getsigmask(&sa, &sigs)); ASSERT_FALSE(sigismember(&sigs, SIGALRM)); sigset_t just_SIGALRM; sigemptyset(&just_SIGALRM); sigaddset(&just_SIGALRM, SIGALRM); ASSERT_EQ(0, posix_spawnattr_setsigmask(&sa, &just_SIGALRM)); ASSERT_EQ(0, posix_spawnattr_getsigmask(&sa, &sigs)); ASSERT_TRUE(sigismember(&sigs, SIGALRM)); ASSERT_EQ(0, posix_spawnattr_destroy(&sa)); }
static int l_posix_spawnattr_getsigmask(lua_State *L) { int r; posix_spawnattr_t *attr = luaL_checkudata(L, 1, "posix_spawnattr_t"); sigset_t *set = luaL_testudata(L, 2, "sigset_t"); if (set) { lua_settop(L, 2); } else { lua_settop(L, 1); set = lua_newuserdata(L, sizeof(sigset_t)); luaL_setmetatable(L, "sigset_t"); } if (0 != (r = posix_spawnattr_getsigmask(attr, set))) { lua_pushnil(L); lua_pushstring(L, strerror(r)); lua_pushinteger(L, r); return 3; } return 1; }
/** * @fn : tc_libc_spawn_posix_spawnattr_SetGetsigmask * @brief : sets and gets the spawn-sigmask attribute in an initialized attributes object referenced by st_attr * @scenario : The spawn-sigmask attribute represents the signal mask in effect in the new process image of a spawn operation * @API's covered : posix_spawnattr_init, posix_spawnattr_setsigmask, posix_spawnattr_getsigmask * @Preconditions : posix_spawnattr_init * @Postconditions : none * @Return : void */ static void tc_libc_spawn_posix_spawnattr_setgetsigmask(void) { posix_spawnattr_t st_attr; int ret_chk = ERROR; sigset_t setMask = MIN_SIGNO; sigset_t getMask; pid_t pid; ret_chk = posix_spawnattr_init(&st_attr); TC_ASSERT_EQ("posix_spawnattr_init", ret_chk, OK); ret_chk = posix_spawnattr_setsigmask(&st_attr, &setMask); TC_ASSERT_EQ("posix_spawnattr_setsigmask", ret_chk, OK); ret_chk = task_spawn(&pid, "spawn_sigmask", function_name_spawn, NULL, &st_attr, (char *const *)NULL, (char *const *)NULL); sleep(SEC_4); TC_ASSERT_EQ("task_spawn", ret_chk, OK); ret_chk = posix_spawnattr_getsigmask(&st_attr, &getMask); TC_ASSERT_EQ("posix_spawnattr_getsigmask", ret_chk, OK); TC_ASSERT_EQ("posix_spawnattr_getsigmask", setMask, getMask); TC_SUCCESS_RESULT(); }