这篇教程C++ umask函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中umask函数的典型用法代码示例。如果您正苦于以下问题:C++ umask函数的具体用法?C++ umask怎么用?C++ umask使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了umask函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: lxc_monitord_spawn/* used to spawn a monitord either on startup of a daemon container, or when * lxc-monitor starts */int lxc_monitord_spawn(const char *lxcpath){ pid_t pid1,pid2; int pipefd[2]; char pipefd_str[11]; char * const args[] = { "/usr/bin/lxc-monitord", (char *)lxcpath, pipefd_str, NULL, }; /* double fork to avoid zombies when monitord exits */ pid1 = fork(); if (pid1 < 0) { SYSERROR("failed to fork"); return -1; } if (pid1) { if (waitpid(pid1, NULL, 0) != pid1) return -1; return 0; } if (pipe(pipefd) < 0) { SYSERROR("failed to create pipe"); exit(EXIT_FAILURE); } pid2 = fork(); if (pid2 < 0) { SYSERROR("failed to fork"); exit(EXIT_FAILURE); } if (pid2) { char c; /* wait for daemon to create socket */ close(pipefd[1]); /* sync with child, we're ignoring the return from read * because regardless if it works or not, either way we've * synced with the child process. the if-empty-statement * construct is to quiet the warn-unused-result warning. */ if (read(pipefd[0], &c, 1)) ; close(pipefd[0]); exit(EXIT_SUCCESS); } umask(0); if (setsid() < 0) { SYSERROR("failed to setsid"); exit(EXIT_FAILURE); } close(0); close(1); close(2); open("/dev/null", O_RDONLY); open("/dev/null", O_RDWR); open("/dev/null", O_RDWR); close(pipefd[0]); sprintf(pipefd_str, "%d", pipefd[1]); execvp(args[0], args); exit(EXIT_FAILURE);}
开发者ID:abstrakraft,项目名称:lxc-android-lxc,代码行数:69,
示例2: mainint main(int argc, char **argv) { // Recovery needs to install world-readable files, so clear umask // set by init umask(0); Log_Offset = 0; // Set up temporary log file (/tmp/recovery.log) freopen(TMP_LOG_FILE, "a", stdout); setbuf(stdout, NULL); freopen(TMP_LOG_FILE, "a", stderr); setbuf(stderr, NULL); signal(SIGPIPE, SIG_IGN); // Handle ADB sideload if (argc == 3 && strcmp(argv[1], "--adbd") == 0) { property_set("ctl.stop", "adbd"); adb_main(argv[2]); return 0; }#ifdef RECOVERY_SDCARD_ON_DATA datamedia = true;#endif char crash_prop_val[PROPERTY_VALUE_MAX]; int crash_counter; property_get("twrp.crash_counter", crash_prop_val, "-1"); crash_counter = atoi(crash_prop_val) + 1; snprintf(crash_prop_val, sizeof(crash_prop_val), "%d", crash_counter); property_set("twrp.crash_counter", crash_prop_val); property_set("ro.twrp.boot", "1"); property_set("ro.twrp.version", TW_VERSION_STR); time_t StartupTime = time(NULL); printf("Starting TWRP %s on %s (pid %d)/n", TW_VERSION_STR, ctime(&StartupTime), getpid());#ifdef HAVE_SELINUX printf("Setting SELinux to permissive/n"); TWFunc::write_file("/sys/fs/selinux/enforce", "0"); TWFunc::write_file("/file_contexts", "/n/n# MultiROM folders/n" "/data/media/multirom(/.*)? <<none>>/n" "/data/media/0/multirom(/.*)? <<none>>/n" "/realdata/media/multirom(/.*)? <<none>>/n" "/realdata/media/0/multirom(/.*)? <<none>>/n" "/sdcard/multirom(/.*)? <<none>>/n" "/mnt/mrom(/.*)? <<none>>/n", "ae");#endif // MultiROM _might_ have crashed the recovery while the boot device was redirected. // It would be bad to let that as is. MultiROM::failsafeCheckPartition("/tmp/mrom_fakebootpart"); MultiROM::failsafeCheckPartition("/tmp/mrom_fakesyspart"); // Load default values to set DataManager constants and handle ifdefs DataManager::SetDefaultValues(); printf("Starting the UI..."); gui_init(); printf("=> Linking mtab/n"); symlink("/proc/mounts", "/etc/mtab"); if (TWFunc::Path_Exists("/etc/twrp.fstab")) { if (TWFunc::Path_Exists("/etc/recovery.fstab")) { printf("Renaming regular /etc/recovery.fstab -> /etc/recovery.fstab.bak/n"); rename("/etc/recovery.fstab", "/etc/recovery.fstab.bak"); } printf("Moving /etc/twrp.fstab -> /etc/recovery.fstab/n"); rename("/etc/twrp.fstab", "/etc/recovery.fstab"); } printf("=> Processing recovery.fstab/n"); if (!PartitionManager.Process_Fstab("/etc/recovery.fstab", 1)) { LOGERR("Failing out of recovery due to problem with recovery.fstab./n"); return -1; } PartitionManager.Output_Partition_Logging(); DataManager::SetValue(TW_MROM_REC_VERSION_VAR, MultiROM::getRecoveryVersion()); printf("MultiROM Recovery version: %s/n", DataManager::GetStrValue(TW_MROM_REC_VERSION_VAR).c_str()); // Load up all the resources gui_loadResources();#ifdef HAVE_SELINUX if (TWFunc::Path_Exists("/prebuilt_file_contexts")) { if (TWFunc::Path_Exists("/file_contexts")) { printf("Renaming regular /file_contexts -> /file_contexts.bak/n"); rename("/file_contexts", "/file_contexts.bak"); } printf("Moving /prebuilt_file_contexts -> /file_contexts/n"); rename("/prebuilt_file_contexts", "/file_contexts"); } struct selinux_opt selinux_options[] = { { SELABEL_OPT_PATH, "/file_contexts" } }; selinux_handle = selabel_open(SELABEL_CTX_FILE, selinux_options, 1); if (!selinux_handle) printf("No file contexts for SELinux/n");//.........这里部分代码省略.........
开发者ID:teemodk,项目名称:android_bootable_recovery,代码行数:101,
示例3: Rename_INIT//.........这里部分代码省略......... return; } else if ( f ) { /* parent */ exit ( 0 ); } /* child continues */ /*** detach from controlling tty ***//* TIOCNOTT not in the Solaris 7 operating environment fd = open ( "/dev/tty", O_RDWR ); ioctl ( fd, TIOCNOTTY, 0 ); close ( fd );*/ #else printf ( "/n Rename_SharedSocketServer: TEST_FLAG set - fork/detach suppressed .../n" );#endif /*** change directory to / ***/ /* chdir ( "/" ); */ /* printf ( "Rename_SharedSocketServer: chdir / suppressed .../n" ); */ /*** set umask ***/ umask ( 027 ); /*** set parent process group ***/ setpgid ( 0, getpid () ); /*** acquire exclusive lock ***/ lf = open ( ( char * ) _lockfile, O_RDWR | O_CREAT, 0640 ); if ( lf < 0 ) { /* error */ printf ( "/n Rename_INIT: unable to open %s O_RDWR | O_CREAT - errno %d/n", ( char * ) _lockfile, errno ); * _rep = FALSE; return; }/* if ( flock ( lf, LOCK_EX | LOCK_NB ) ) { /? can't obtain exclusive lock ?/ printf ( "/n Rename_INIT: unable to obtain lock on %s - errno %d/n", ( char * ) _lockfile, errno ); * _rep = FALSE; return; }*/ /*** perform malloc for _out_buf & _in_buf
开发者ID:edwardcrichton,项目名称:BToolkit,代码行数:67,
示例4: maybe_create_keybox/* Handle the creation of a keybox if it does not yet exist. Take into acount that other processes might have the keybox already locked. This lock check does not work if the directory itself is not yet available. If R_CREATED is not NULL it will be set to true if the function created a new keybox. */static intmaybe_create_keybox (char *filename, int force, int *r_created){ dotlock_t lockhd = NULL; FILE *fp; int rc; mode_t oldmask; char *last_slash_in_filename; int save_slash; if (r_created) *r_created = 0; /* A quick test whether the filename already exists. */ if (!access (filename, F_OK)) return 0; /* If we don't want to create a new file at all, there is no need to go any further - bail out right here. */ if (!force) return gpg_error (GPG_ERR_ENOENT); /* First of all we try to create the home directory. Note, that we don't do any locking here because any sane application of gpg would create the home directory by itself and not rely on gpg's tricky auto-creation which is anyway only done for some home directory name patterns. */ last_slash_in_filename = strrchr (filename, DIRSEP_C);#if HAVE_W32_SYSTEM { /* Windows may either have a slash or a backslash. Take care of it. */ char *p = strrchr (filename, '/'); if (!last_slash_in_filename || p > last_slash_in_filename) last_slash_in_filename = p; }#endif /*HAVE_W32_SYSTEM*/ if (!last_slash_in_filename) return gpg_error (GPG_ERR_ENOENT); /* No slash at all - should not happen though. */ save_slash = *last_slash_in_filename; *last_slash_in_filename = 0; if (access(filename, F_OK)) { static int tried; if (!tried) { tried = 1; try_make_homedir (filename); } if (access (filename, F_OK)) { rc = gpg_error_from_syserror (); *last_slash_in_filename = save_slash; goto leave; } } *last_slash_in_filename = save_slash; /* To avoid races with other instances of gpg trying to create or update the keybox (it is removed during an update for a short time), we do the next stuff in a locked state. */ lockhd = dotlock_create (filename, 0); if (!lockhd) { /* A reason for this to fail is that the directory is not writable. However, this whole locking stuff does not make sense if this is the case. An empty non-writable directory with no keyring is not really useful at all. */ if (opt.verbose) log_info ("can't allocate lock for '%s'/n", filename ); if (!force) return gpg_error (GPG_ERR_ENOENT); else return gpg_error (GPG_ERR_GENERAL); } if ( dotlock_take (lockhd, -1) ) { /* This is something bad. Probably a stale lockfile. */ log_info ("can't lock '%s'/n", filename); rc = gpg_error (GPG_ERR_GENERAL); goto leave; } /* Now the real test while we are locked. */ if (!access(filename, F_OK)) { rc = 0; /* Okay, we may access the file now. */ goto leave; } /* The file does not yet exist, create it now. */ oldmask = umask (077);//.........这里部分代码省略.........
开发者ID:MacGyverNL,项目名称:gnupg-vanity,代码行数:101,
示例5: pthread_detachvoid *thread_func(void *arg){ char localpath[PATH_MAX] = {'/0'}; message_t *pids = (message_t *)arg; char mqRd[PATH_MAX] = {'/0'}; char mqWr[PATH_MAX] = {'/0'}; pid_t pid = (int)strtol(pids->command, NULL, 10); int s = 0; pthread_detach(pthread_self()); clients++; // printf("%d client connected/n", pid); CREATE_CLIENT_READER_NAME(mqRd, (int)pid); CREATE_CLIENT_WRITER_NAME(mqWr, (int)pid); free(pids); umask(0); s = pthread_mutex_lock(&mtx); if (s != 0) printf("Lock failed/n"); getcwd(localpath, sizeof(localpath)); s = pthread_mutex_unlock(&mtx); if (s != 0) printf("Unlock failed/n"); while (1) { mqd_t cwr, crd; message_t data; memset(&data, '/0', sizeof(data)); if ((cwr = mq_open(mqWr, O_RDONLY)) == -1) { printf("Open write queue failed!/n"); clients--; pthread_exit(EXIT_SUCCESS); } mq_receive(cwr, (char *)&data, sizeof(data), NULL); mq_close(cwr); if (strcmp(data.command, CMD_EXIT) == 0) { clients--; // printf("%d client exit/n", pid); pthread_exit(EXIT_SUCCESS); } else if (strcmp(data.command, CMD_REMOTE_CHDIR) == 0) { int ts; char local[PATH_MAX] = {'/0'}; char res[PATH_MAX] = {'/0'}; ts = pthread_mutex_lock(&mtx); if (ts != 0) printf("Lock failed/n"); getcwd(local, sizeof(local)); if (chdir(localpath) == -1) { printf("Cannot change directory/n"); continue; } if (chdir(data.payload) == -1) memcpy(res, "ERROR/n", strlen("ERROR/n")); else getcwd(res, sizeof(res)); memset(&data, '/0', sizeof(data)); memcpy(data.payload, res, strlen(res)); if (strcmp(res, "ERROR/n") != 0) { memset(localpath, '/0', sizeof(localpath)); memcpy(localpath, res, strlen(res)); } if ((crd = mq_open(mqRd, O_WRONLY)) == -1) { printf("Cannot open read queue/n"); continue; } mq_send(crd, (char *)&data, sizeof(data), 0); mq_close(crd); if (chdir(local) == -1) { printf("Cannot restore directory/n"); continue; } ts = pthread_mutex_unlock(&mtx); if (ts != 0) printf("Unlock failed/n"); }//cd else if (strcmp(data.command, CMD_REMOTE_DIR) == 0) { char cmd[PATH_MAX] = {'/0'}; FILE *fp; memcpy(cmd, CMD_LS_POPEN, strlen(CMD_LS_POPEN)); strcat(cmd, " ");//.........这里部分代码省略.........
开发者ID:Rasadell09,项目名称:cs344,代码行数:101,
示例6: UID_DIGITSSHMem *SHMem::initSegment(const char *name, int size, bool &init){ bool needInit = true; /* big enough to hold a uid_t value in decimal */ /* decimal digits = ceiling(log10(uid_t_max)); */ /* log10(uid_t_max) = log256(uid_t_max)/log256(10); */ /* log256(uid_t_max) = sizeof(uid_t); */ /* log10(256) just greater than .41 */ /* so decimal_digits = (sizeof(uid_t)*100 +40)/41 */#define UID_DIGITS (((sizeof(uid_t)*100)+40)/41) char uid_str[UID_DIGITS+2]; /* 1 for '-', 1 for null */ init = 0; SHMemData *shmemData = new SHMemData; if (!shmemData ) { // applications know we failed because they will get a NULL address // from getSHMemAddr. return NULL; } int mask = umask(0); int ret = mkdir (MEMSEGPATH, 01777); umask(mask); if ((ret == -1) && (errno != EEXIST)) { delete shmemData; return NULL; } /* 1 for the '/', one for the '-' and one for the null */ shmemData->path = new char [sizeof(MEMSEGPATH)+strlen(name)+UID_DIGITS+3]; if (shmemData->path == NULL) { delete shmemData; return NULL; } memcpy(shmemData->path,MEMSEGPATH, sizeof(MEMSEGPATH)); shmemData->path[sizeof(MEMSEGPATH)-1] = '/'; strcpy(&shmemData->path[sizeof(MEMSEGPATH)],name); sprintf(uid_str, "-%u",getuid()); strcat(shmemData->path,uid_str); int mode = 0600; shmemData->fd = open(shmemData->path, O_CREAT|O_RDWR|O_EXCL|O_APPEND|O_EXLOCK, mode); if (shmemData->fd >= 0) { char *buf; int len = size+RESERVED_OFFSET; int ret; buf = (char *)calloc(1,len); if (!buf) { unlink(shmemData->path);#ifdef FULL_CLEANUP flock(shmemData->fd, LOCK_UN);#endif delete shmemData; return NULL; } ret = write(shmemData->fd,buf,len); if (ret != len) { unlink(shmemData->path);#ifdef FULL_CLEANUP flock(shmemData->fd, LOCK_UN);#endif delete shmemData; return NULL; } free(buf); } else if (errno == EEXIST) { needInit = false; shmemData->fd = safe_open(shmemData->path,O_RDWR|O_EXLOCK, mode, size+RESERVED_OFFSET); } if (shmemData->fd < 0) { delete shmemData; return NULL; } shmemData->addr = (char *) mmap(0, size+RESERVED_OFFSET, PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED|MAP_INHERIT, shmemData->fd, 0); if (shmemData->addr == NULL) { if (needInit) { unlink(shmemData->path); }#ifdef FULL_CLEANUP flock(shmemData->fd, LOCK_UN);#endif delete shmemData; return NULL; } shmemData->size = size;#ifdef FULL_CLEANUP (*(unsigned long *)shmemData->addr)++; flock(shmemData->fd, LOCK_UN);#endif init = needInit; SHMem *memseg; memseg = new SHMem(); if (!memseg) { delete shmemData;//.........这里部分代码省略.........
开发者ID:Vanuan,项目名称:coolkey,代码行数:101,
示例7: mainint main(int argc,char *argv[]){ struct pgpmainBones *mainbPtr = &_pgp_mainBones; struct pgpargsBones *argsbPtr; struct pgpfileBones *filebPtr; struct pgpenvBones *envbPtr; PGPContextRef mainContext; int errorLvl = 0, status; PGPError err = PGPsdkInit(); pgpAssertNoErr(err); err = PGPsdkNetworkLibInit(); pgpAssertNoErr(err); err = PGPNewContext( kPGPsdkAPIVersion, &mainContext ); pgpAssertNoErr(err); err = pgpInitSDKPrefsDir( mainContext ); pgpAssertNoErr(err); initMainBones( mainbPtr, mainContext ); signonMsg(mainbPtr); /* link the context and initialize what used to be the global variables. */ argsbPtr = mainbPtr->argsbPtr; filebPtr = mainbPtr->filebPtr; envbPtr = mainbPtr->envbPtr; err = pgpParseArgs( mainbPtr, argc, argv, &errorLvl); /* parse the arguments */ if(err != 0) goto ex; if (argsbPtr->keyFlag && argsbPtr->keyChar == '/0') { keyUsage(filebPtr,&errorLvl); goto ex; } if (argsbPtr->groupFlag && argsbPtr->groupChar == '/0') { groupUsage(filebPtr,&errorLvl); goto ex; } /* * Write to stdout if explicitly asked to, or in filter mode and * no explicit file name was given. */ mainbPtr->outputStdout = argsbPtr->outputFileName ? strcmp(argsbPtr->outputFileName, "-") == 0 : envbPtr->filterMode;#if 1 /* At request of Peter Simons, use stderr always. Sounds reasonable. */ /* JIS: Put this code back in... removing it broke too many things */ if (!mainbPtr->outputStdout) filebPtr->pgpout = stdout;#endif#if defined(PGP_UNIX) || defined(VMS) umask(077); /* Make files default to private */#endif initSignals(); /* Catch signals */ /* get our groups...*/ err = pgpInitializeWorkingGroupSet( mainbPtr ); if (argsbPtr->keyFlag) { status = doKeyOpt( mainbPtr, argsbPtr->keyChar, &errorLvl ); if (status < 0) { userError(filebPtr,&errorLvl); goto ex; } errorLvl=status; goto ex; } if(argsbPtr->groupFlag) { status = doGroupOpt( mainbPtr, argsbPtr->groupChar, &errorLvl ); if( status < 0 ) { userError(filebPtr,&errorLvl); goto ex; } errorLvl=status; goto ex; } err = pgpProcessArgs(mainbPtr, &errorLvl);ex: err = pgpFinalizeWorkingGroupSet( mainbPtr ); pgpTearDown( mainbPtr, &errorLvl ); exit(errorLvl); /*NOTREACHED*/ return errorLvl;}
开发者ID:ysangkok,项目名称:pgp-win32-6.5.8,代码行数:98,
示例8: service_startvoid service_start(struct service *svc, const char *dynamic_args){ struct stat s; pid_t pid; int needs_console; char *scon = NULL; int rc; /* starting a service removes it from the disabled or reset * state and immediately takes it out of the restarting * state if it was in there */ svc->flags &= (~(SVC_DISABLED|SVC_RESTARTING|SVC_RESET|SVC_RESTART|SVC_DISABLED_START)); svc->time_started = 0; /* running processes require no additional work -- if * they're in the process of exiting, we've ensured * that they will immediately restart on exit, unless * they are ONESHOT */ if (svc->flags & SVC_RUNNING) { return; } needs_console = (svc->flags & SVC_CONSOLE) ? 1 : 0; if (needs_console && (!have_console)) { ERROR("service '%s' requires console/n", svc->name); svc->flags |= SVC_DISABLED; return; } if (stat(svc->args[0], &s) != 0) { ERROR("cannot find '%s', disabling '%s'/n", svc->args[0], svc->name); svc->flags |= SVC_DISABLED; return; } if ((!(svc->flags & SVC_ONESHOT)) && dynamic_args) { ERROR("service '%s' must be one-shot to use dynamic args, disabling/n", svc->args[0]); svc->flags |= SVC_DISABLED; return; } if (is_selinux_enabled() > 0) { if (svc->seclabel) { scon = strdup(svc->seclabel); if (!scon) { ERROR("Out of memory while starting '%s'/n", svc->name); return; } } else { char *mycon = NULL, *fcon = NULL; INFO("computing context for service '%s'/n", svc->args[0]); rc = getcon(&mycon); if (rc < 0) { ERROR("could not get context while starting '%s'/n", svc->name); return; } rc = getfilecon(svc->args[0], &fcon); if (rc < 0) { ERROR("could not get context while starting '%s'/n", svc->name); freecon(mycon); return; } rc = security_compute_create(mycon, fcon, string_to_security_class("process"), &scon); if (rc == 0 && !strcmp(scon, mycon)) { ERROR("Warning! Service %s needs a SELinux domain defined; please fix!/n", svc->name); } freecon(mycon); freecon(fcon); if (rc < 0) { ERROR("could not get context while starting '%s'/n", svc->name); return; } } } NOTICE("starting '%s'/n", svc->name); pid = fork(); if (pid == 0) { struct socketinfo *si; struct svcenvinfo *ei; char tmp[32]; int fd, sz; umask(077); if (properties_inited()) { get_property_workspace(&fd, &sz); sprintf(tmp, "%d,%d", dup(fd), sz); add_environment("ANDROID_PROPERTY_WORKSPACE", tmp); } for (ei = svc->envvars; ei; ei = ei->next) add_environment(ei->name, ei->value);//.........这里部分代码省略.........
开发者ID:2Habibie,项目名称:platform_system_core,代码行数:101,
示例9: mainint main(int argc, char **argv){ int fd_count = 0; struct pollfd ufds[4]; int property_set_fd_init = 0; int signal_fd_init = 0; int keychord_fd_init = 0; bool is_charger = false; if (!strcmp(basename(argv[0]), "ueventd")) return ueventd_main(argc, argv); if (!strcmp(basename(argv[0]), "watchdogd")) return watchdogd_main(argc, argv); /* clear the umask */ umask(0); /* Get the basic filesystem setup we need put * together in the initramdisk on / and then we'll * let the rc file figure out the rest. */ mkdir("/dev", 0755); mkdir("/proc", 0755); mkdir("/sys", 0755); mount("tmpfs", "/dev", "tmpfs", MS_NOSUID, "mode=0755"); mkdir("/dev/pts", 0755); mkdir("/dev/socket", 0755); mount("devpts", "/dev/pts", "devpts", 0, NULL); mount("proc", "/proc", "proc", 0, NULL); mount("sysfs", "/sys", "sysfs", 0, NULL); /* indicate that booting is in progress to background fw loaders, etc */ close(open("/dev/.booting", O_WRONLY | O_CREAT, 0000)); /* We must have some place other than / to create the * device nodes for kmsg and null, otherwise we won't * be able to remount / read-only later on. * Now that tmpfs is mounted on /dev, we can actually * talk to the outside world. */ open_devnull_stdio(); klog_init(); property_init(); get_hardware_name(hardware, &revision); process_kernel_cmdline(); union selinux_callback cb; cb.func_log = log_callback; selinux_set_callback(SELINUX_CB_LOG, cb); cb.func_audit = audit_callback; selinux_set_callback(SELINUX_CB_AUDIT, cb); selinux_initialize(); /* These directories were necessarily created before initial policy load * and therefore need their security context restored to the proper value. * This must happen before /dev is populated by ueventd. */ restorecon("/dev"); restorecon("/dev/socket"); restorecon("/dev/__properties__"); restorecon_recursive("/sys"); is_charger = !strcmp(bootmode, "charger"); INFO("property init/n"); property_load_boot_defaults(); INFO("reading config file/n"); init_parse_config_file("/init.rc"); action_for_each_trigger("early-init", action_add_queue_tail); queue_builtin_action(wait_for_coldboot_done_action, "wait_for_coldboot_done"); queue_builtin_action(mix_hwrng_into_linux_rng_action, "mix_hwrng_into_linux_rng"); queue_builtin_action(keychord_init_action, "keychord_init"); queue_builtin_action(console_init_action, "console_init"); /* execute all the boot actions to get us started */ action_for_each_trigger("init", action_add_queue_tail); /* Repeat mix_hwrng_into_linux_rng in case /dev/hw_random or /dev/random * wasn't ready immediately after wait_for_coldboot_done */ queue_builtin_action(mix_hwrng_into_linux_rng_action, "mix_hwrng_into_linux_rng"); queue_builtin_action(property_service_init_action, "property_service_init"); queue_builtin_action(signal_init_action, "signal_init"); /* Don't mount filesystems or start core system services if in charger mode. */ if (is_charger) { action_for_each_trigger("charger", action_add_queue_tail); } else { action_for_each_trigger("late-init", action_add_queue_tail); } /* run all property triggers based on current state of the properties *///.........这里部分代码省略.........
开发者ID:2Habibie,项目名称:platform_system_core,代码行数:101,
示例10: initstatic int init(char *argv[]) { struct stat fstatus; struct group *group; cp_string filename; const char *uri=cupsBackendDeviceURI(argv); if ((uri != NULL) && (strncmp(uri, "cups-pdf:/", 10) == 0) && strlen(uri) > 10) { uri = uri + 10; sprintf(filename, "%s/cups-pdf-%s.conf", CP_CONFIG_PATH, uri); } else { sprintf(filename, "%s/cups-pdf.conf", CP_CONFIG_PATH); } read_config_file(filename); cwwdebug(filename); read_config_ppd(); read_config_options(argv[5]); (void) umask(0077); group=getgrnam(Conf_Grp); if (group) (void) setgid(group->gr_gid); cwwdebug(Conf_Log); if (strlen(Conf_Log)) { if (stat(Conf_Log, &fstatus) || !S_ISDIR(fstatus.st_mode)) { if (create_dir(Conf_Log, 1)) return 1; if (chmod(Conf_Log, 0700)) return 1; } snprintf(filename, BUFSIZE, "%s/%s%s%s", Conf_Log, "cups-pdf-", getenv("PRINTER"), "_log"); logfp=fopen(filename, "a"); } char tmpstr[100]; *tmpstr = '/0'; sprintf(tmpstr, "uid = %d, euid = %d", getuid(), geteuid()); cwwdebug(tmpstr); if (logfp == NULL) { cwwdebug(strerror(errno)); cwwdebug("logfp == NULL"); } cwwdebug(filename); dump_configuration(); if (!group) { log_event(CPERROR, "Grp not found: %s", Conf_Grp); return 1; } else log_event(CPDEBUG, "switching to new gid: %s", Conf_Grp); cwwdebug("group"); (void) umask(0022); cwwdebug("umask"); cwwdebug(Conf_Spool); if (stat(Conf_Spool, &fstatus) || !S_ISDIR(fstatus.st_mode)) { if (create_dir(Conf_Spool, 0)) { log_event(CPERROR, "failed to create spool directory: %s", Conf_Spool); return 1; } cwwdebug("create_dir(Conf_Spool, 0) success!"); if (chmod(Conf_Spool, 0751)) { log_event(CPERROR, "failed to set mode on spool directory: %s", Conf_Spool); return 1; } cwwdebug("chmod(Conf_Spool, 0751) success!"); if (chown(Conf_Spool, -1, group->gr_gid)) log_event(CPERROR, "failed to set group id %s on spool directory: %s (non fatal)", Conf_Grp, Conf_Spool); log_event(CPSTATUS, "spool directory created: %s", Conf_Spool); } cwwdebug("stat"); (void) umask(0077); return 0;}
开发者ID:caiweiwenjs,项目名称:cfilter,代码行数:76,
示例11: main//.........这里部分代码省略......... if (gscall == NULL) { (void) fputs("CUPS-PDF: failed to allocate memory/n", stderr); if (unlink(spoolfile)) log_event(CPERROR, "failed to unlink spoolfile during clean-up: %s", spoolfile); free(groups); free(dirname); free(spoolfile); free(outfile); if (logfp!=NULL) (void) fclose(logfp); return 5; } snprintf(gscall, size, Conf_GSCall, Conf_GhostScript, Conf_PDFVer, outfile, spoolfile); log_event(CPDEBUG, "ghostscript commandline built: %s", gscall); (void) unlink(outfile); log_event(CPDEBUG, "output file unlinked: %s", outfile); if (putenv(Conf_GSTmp)) { log_event(CPERROR, "insufficient space in environment to set TMPDIR: %s", Conf_GSTmp); if (unlink(spoolfile)) log_event(CPERROR, "failed to unlink spoolfile during clean-up: %s", spoolfile); free(groups); free(dirname); free(spoolfile); free(outfile); free(gscall); if (logfp!=NULL) (void) fclose(logfp); return 5; } log_event(CPDEBUG, "TMPDIR set for GhostScript: %s", getenv("TMPDIR")); pid=fork(); if (!pid) { log_event(CPDEBUG, "entering child process"); if (setgid(passwd->pw_gid)) log_event(CPERROR, "failed to set GID for current user"); else log_event(CPDEBUG, "GID set for current user"); if (setgroups(ngroups, groups)) log_event(CPERROR, "failed to set supplementary groups for current user"); else log_event(CPDEBUG, "supplementary groups set for current user"); if (setuid(passwd->pw_uid)) log_event(CPERROR, "failed to set UID for current user: %s", passwd->pw_name); else log_event(CPDEBUG, "UID set for current user: %s", passwd->pw_name); (void) umask(0077); size=system(gscall); log_event(CPDEBUG, "ghostscript has finished: %d", size); if (chmod(outfile, mode)) log_event(CPERROR, "failed to set file mode for PDF file: %s (non fatal)", outfile); else log_event(CPDEBUG, "file mode set for user output: %s", outfile); if (strlen(Conf_PostProcessing)) { size=strlen(Conf_PostProcessing)+strlen(outfile)+strlen(passwd->pw_name)+strlen(argv[2])+4; ppcall=calloc(size, sizeof(char)); if (ppcall == NULL) log_event(CPERROR, "failed to allocate memory for postprocessing (non fatal)"); else { snprintf(ppcall, size, "%s %s %s %s", Conf_PostProcessing, outfile, passwd->pw_name, argv[2]); log_event(CPDEBUG, "postprocessing commandline built: %s", ppcall); size=system(ppcall); snprintf(title,BUFSIZE,"%d",size); log_event(CPDEBUG, "postprocessing has finished: %s", title); free(ppcall); } } else log_event(CPDEBUG, "no postprocessing"); return 0; } log_event(CPDEBUG, "waiting for child to exit"); (void) waitpid(pid,NULL,0); if (unlink(spoolfile)) log_event(CPERROR, "failed to unlink spoolfile: %s (non fatal)", spoolfile); else log_event(CPDEBUG, "spoolfile unlinked: %s", spoolfile); free(groups); free(dirname); free(spoolfile); free(outfile); free(gscall); log_event(CPDEBUG, "all memory has been freed"); log_event(CPSTATUS, "PDF creation successfully finished for %s", passwd->pw_name); if (logfp!=NULL) (void) fclose(logfp); return 0;}
开发者ID:caiweiwenjs,项目名称:cfilter,代码行数:101,
示例12: main//.........这里部分代码省略......... if (gid != -1 && (getgid() != gid) && setgid(gid)) { tvhlog(LOG_ALERT, "START", "setgid(%d) failed, do you have permission?", gid); return 1; } if (uid != -1 && (getuid() != uid) && setuid(uid)) { tvhlog(LOG_ALERT, "START", "setuid(%d) failed, do you have permission?", uid); return 1; } /* Daemonise */ if(opt_fork) { if(daemon(0, 0)) { exit(2); } if(pidfile != NULL) { fprintf(pidfile, "%d/n", getpid()); fclose(pidfile); } /* Make dumpable */ if (opt_dump) {#ifdef PLATFORM_LINUX if (chdir("/tmp")) tvhwarn("START", "failed to change cwd to /tmp"); prctl(PR_SET_DUMPABLE, 1);#else tvhwarn("START", "Coredumps not implemented on your platform");#endif } umask(0); } tvheadend_running = 1; /* Start log thread (must be done post fork) */ tvhlog_start(); /* Alter logging */ if (opt_fork) tvhlog_options &= ~TVHLOG_OPT_STDERR; if (!isatty(2)) tvhlog_options &= ~TVHLOG_OPT_DECORATE; /* Initialise clock */ pthread_mutex_lock(&global_lock); time(&dispatch_clock); /* Signal handling */ sigfillset(&set); sigprocmask(SIG_BLOCK, &set, NULL); trap_init(argv[0]); /* SSL library init */ OPENSSL_config(NULL); SSL_load_error_strings(); SSL_library_init(); /* Initialise configuration */ notify_init(); idnode_init(); spawn_init(); config_init(opt_nobackup == 0);
开发者ID:dreamcat4,项目名称:tvheadend,代码行数:67,
示例13: asynclog_open/** Opens the asynchronous request store. */static std::shared_ptr<folly::File> asynclog_open(proxy_t *proxy) { char path[PATH_MAX + 1]; time_t now = time(nullptr); pid_t tid = syscall(SYS_gettid); struct tm date; struct stat st; int success = 0; int fd = -1; if (proxy->async_fd && now - proxy->async_spool_time <= DEFAULT_ASYNCLOG_LIFETIME) { return proxy->async_fd; } if (proxy->async_fd) { proxy->async_fd = nullptr; } localtime_r(&now, &date); char hour_path[PATH_MAX+1]; time_t hour_time = now - (now % 3600); if (snprintf(hour_path, PATH_MAX, "%s/%04d%02d%02dT%02d-%lld", proxy->router().opts().async_spool.c_str(), date.tm_year + 1900, date.tm_mon + 1, date.tm_mday, date.tm_hour, (long long) hour_time) > PATH_MAX) { hour_path[PATH_MAX] = '/0'; LOG(ERROR) << "async log hourly spool path is too long: " << hour_path; goto epilogue; } if (stat(hour_path, &st) != 0) { mode_t old_umask = umask(0); int ret = mkdir(hour_path, 0777); int mkdir_errno = 0; if (ret != 0) { mkdir_errno = errno; } if (old_umask != 0) { umask(old_umask); } /* EEXIST is possible due to a race. We don't care. */ if (ret != 0 && mkdir_errno != EEXIST) { LOG(ERROR) << "couldn't create async log hour spool path: " << hour_path << ". reason: " << strerror(mkdir_errno); goto epilogue; } } if (snprintf(path, PATH_MAX, "%s/%04d%02d%02dT%02d%02d%02d-%lld-%s-%s-t%d-%p", hour_path, date.tm_year + 1900, date.tm_mon + 1, date.tm_mday, date.tm_hour, date.tm_min, date.tm_sec, (long long) now, proxy->router().opts().service_name.c_str(), proxy->router().opts().router_name.c_str(), tid, proxy) > PATH_MAX) { path[PATH_MAX] = '/0'; LOG(ERROR) << "async log path is too long: " << path; goto epilogue; } /* * Just in case, append to the log if it exists */ if (stat(path, &st) != 0) { fd = open(path, O_WRONLY | O_CREAT, 0666); if (fd < 0) { LOG(ERROR) << "Can't create and open async store " << path << ": " << strerror(errno); goto epilogue; } } else { fd = open(path, O_WRONLY | O_APPEND, 0666); if (fd < 0) { LOG(ERROR) << "Can't re-open async store " << path << ": " << strerror(errno); goto epilogue; } } if (fstat(fd, &st)) { LOG(ERROR) << "Can't stat async store " << path << ": " << strerror(errno); goto epilogue; } if (!S_ISREG(st.st_mode)) { LOG(ERROR) << "Async store exists but is not a file: " << path << ": " << strerror(errno); goto epilogue; } proxy->async_fd = countedfd_new(fd);//.........这里部分代码省略.........
开发者ID:cicerocomp,项目名称:mcrouter,代码行数:101,
示例14: shm_common_newint shm_common_new(int key, int *size, int instance, void **shmptr, int create){ struct shm_status sm; int retval; int is_new = 0; if (shmdrv_loaded) { // use shmdrv kernel driver sm.driver_fd = shmdrv_driver_fd(); sm.key = key; sm.size = (size == NULL? 0: *size); sm.flags = 0; retval = shmdrv_status(&sm); // check if exists if (retval && !create) { // didnt exist, but just attach requested, so fail close(sm.driver_fd); return -ENOENT; } if (retval) { // didnt exist, so create retval = shmdrv_create(&sm); if (retval < 0) { return retval; } is_new = 1; } // now attach retval = shmdrv_attach(&sm, shmptr); if (retval < 0) { close(sm.driver_fd); return retval; } // if size was passed in as 0 (attach), fill in actual size if (size && (*size == 0)) *size = sm.size; close(sm.driver_fd); return is_new; } else { // use POSIX shared memory int shmfd, mmap_size; mode_t old_umask; char segment_name[LINELEN]; if ((size == 0) || (*size == 0)) mmap_size = 0; else mmap_size = *size; sprintf(segment_name, SHM_FMT, instance, key); old_umask = umask(0); //S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP); if (create && ((shmfd = shm_open(segment_name, (O_CREAT | O_EXCL | O_RDWR), (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP))) > 0)) { // initial creation if (fchown(shmfd, getuid(),getgid())) perror("fchown"); if (ftruncate(shmfd, mmap_size)) perror("ftruncate"); is_new = 1; } else if((shmfd = shm_open(segment_name, O_RDWR, (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP))) < 0) { // just attach, and that failed: umask(old_umask); return -errno; } else { // shmfd open if (mmap_size == 0) { struct stat st; if (fstat(shmfd, &st)) { perror("fstat"); return -errno; } mmap_size = st.st_size; } } if((*shmptr = mmap(0, mmap_size, (PROT_READ | PROT_WRITE), MAP_SHARED, shmfd, 0)) == MAP_FAILED) { perror("shm_common_new:mmap"); close(shmfd); umask(old_umask); return -errno; } if (size) // return actual shm size as determined in attach *size = mmap_size; umask(old_umask); close(shmfd); return is_new; }}
开发者ID:13788593535,项目名称:machinekit,代码行数:87,
示例15: try_update_binary// If the package contains an update binary, extract it and run it.// @param path// 待安装的 ota_pkg 的路径字串. // @param zip// 关联到 'path' 目标文件的 ZipArchive 实例的指针. // @param wipe_cache// 传入 install 流程的 log file 的路径. // static inttry_update_binary(const char *path, ZipArchive *zip, int* wipe_cache) { const ZipEntry* binary_entry = mzFindZipEntry(zip, ASSUMED_UPDATE_BINARY_NAME); if (binary_entry == NULL) { mzCloseZipArchive(zip); return INSTALL_CORRUPT; } const char* binary = "/tmp/update_binary"; unlink(binary); int fd = creat(binary, 0755); if (fd < 0) { mzCloseZipArchive(zip); LOGE("Can't make %s/n", binary); return INSTALL_ERROR; } bool ok = mzExtractZipEntryToFile(zip, binary_entry, fd); close(fd); mzCloseZipArchive(zip); if (!ok) { LOGE("Can't copy %s/n", ASSUMED_UPDATE_BINARY_NAME); return INSTALL_ERROR; } int pipefd[2]; pipe(pipefd); // When executing the update binary contained in the package, the // arguments passed are: // // - the version number for this interface // // - an fd to which the program can write in order to update the // progress bar. The program can write single-line commands: // // progress <frac> <secs> // fill up the next <frac> part of of the progress bar // over <secs> seconds. If <secs> is zero, use // set_progress commands to manually control the // progress of this segment of the bar // // set_progress <frac> // <frac> should be between 0.0 and 1.0; sets the // progress bar within the segment defined by the most // recent progress command. // // firmware <"hboot"|"radio"> <filename> // arrange to install the contents of <filename> in the // given partition on reboot. // // (API v2: <filename> may start with "PACKAGE:" to // indicate taking a file from the OTA package.) // // (API v3: this command no longer exists.) // // ui_print <string> // display <string> on the screen. // // - the name of the package zip file. // const char** args = (const char**)malloc(sizeof(char*) * 5); args[0] = binary; args[1] = EXPAND(RECOVERY_API_VERSION); // defined in Android.mk char* temp = (char*)malloc(10); sprintf(temp, "%d", pipefd[1]); args[2] = temp; args[3] = (char*)path; args[4] = NULL; pid_t pid = fork(); if (pid == 0) { umask(022); close(pipefd[0]); execv(binary, (char* const*)args); fprintf(stdout, "E:Can't run %s (%s)/n", binary, strerror(errno)); _exit(-1); } close(pipefd[1]); *wipe_cache = 0; char buffer[1024]; FILE* from_child = fdopen(pipefd[0], "r"); while (fgets(buffer, sizeof(buffer), from_child) != NULL) { char* command = strtok(buffer, " /n"); if (command == NULL) { continue; } else if (strcmp(command, "progress") == 0) { char* fraction_s = strtok(NULL, " /n");//.........这里部分代码省略.........
开发者ID:morrey,项目名称:firefly-rk3288_android_5.1_sdk,代码行数:101,
示例16: mainint main(int argc, char **argv){ pid_t pid; int flags; /* Fork off the parent process */ pid = fork(); if (pid < 0) { exit(EXIT_FAILURE); } /* If we got a good PID, then we can exit the parent process. */ if (pid > 0) { exit(EXIT_SUCCESS); } /* Change the file mode mask */ umask(0); /* Open any logs here */ /* NONE */ /* Create a new SID for the child process */ if (setsid() < 0) fatal("setsid failed (%m)"); /* Change the current working directory */ if ((chdir("/")) < 0) fatal("chdir failed (%m)"); /* check command line parameters */ initOpts(argc, argv); /* Close out the standard file descriptors */ fclose(stdin); fclose(stdout); /* configure library */ gpioCfgBufferSize(bufferSizeMilliseconds); gpioCfgClock(clockMicros, clockPeripheral, clockSource); gpioCfgInterfaces(ifFlags); gpioCfgDMAchannels(DMAprimaryChannel, DMAsecondaryChannel); gpioCfgSocketPort(socketPort); if (updateMask != -1) gpioCfgPermissions(updateMask); /* start library */ if (gpioInitialise()< 0) fatal("Can't initialise pigpio library"); /* create pipe for error reporting */ unlink(PI_ERRFIFO); mkfifo(PI_ERRFIFO, 0664); if (chmod(PI_ERRFIFO, 0664) < 0) fatal("chmod %s failed (%m)", PI_ERRFIFO); errFifo = freopen(PI_ERRFIFO, "w+", stderr); if (errFifo) { /* set stderr non-blocking */ flags = fcntl(fileno(errFifo), F_GETFL, 0); fcntl(fileno(errFifo), F_SETFL, flags | O_NONBLOCK); /* request SIGHUP/SIGTERM from libarary for termination */ gpioSetSignalFunc(SIGHUP, terminate); gpioSetSignalFunc(SIGTERM, terminate); /* sleep forever */ while (1) { /* cat /dev/pigerr to view daemon errors */ sleep(5); fflush(errFifo); } } else { fprintf(stderr, "freopen failed (%m)"); gpioTerminate(); } return 0;//.........这里部分代码省略.........
开发者ID:Lukas-St,项目名称:Mobile-Rover,代码行数:101,
示例17: build/* * Returns 1 if a directory has been created, * 2 if it already existed, and 0 on failure. */static intbuild(char *path, mode_t omode){ struct stat sb; mode_t numask, oumask; int first, last, retval; char *p; p = path; oumask = 0; retval = 1; if (p[0] == '/') /* Skip leading '/'. */ ++p; for (first = 1, last = 0; !last ; ++p) { if (p[0] == '/0') last = 1; else if (p[0] != '/') continue; *p = '/0'; if (!last && p[1] == '/0') last = 1; if (first) { /* * POSIX 1003.2: * For each dir operand that does not name an existing * directory, effects equivalent to those caused by the * following command shall occcur: * * mkdir -p -m $(umask -S),u+wx $(dirname dir) && * mkdir [-m mode] dir * * We change the user's umask and then restore it, * instead of doing chmod's. */ oumask = umask(0); numask = oumask & ~(S_IWUSR | S_IXUSR); (void)umask(numask); first = 0; } if (last) (void)umask(oumask); if (mkdir(path, last ? omode : S_IRWXU | S_IRWXG | S_IRWXO) < 0) { if (errno == EEXIST || errno == EISDIR) { if (stat(path, &sb) < 0) { warn("%s", path); retval = 0; break; } else if (!S_ISDIR(sb.st_mode)) { if (last) errno = EEXIST; else errno = ENOTDIR; warn("%s", path); retval = 0; break; } if (last) retval = 2; } else { warn("%s", path); retval = 0; break; } } else if (vflag) printf("%s/n", path); if (!last) *p = '/'; } if (!first && !last) (void)umask(oumask); return (retval);}
开发者ID:ele7enxxh,项目名称:dtrace-pf,代码行数:76,
示例18: bb_make_directoryint bb_make_directory (char *path, long mode, int flags){ mode_t mask; const char *fail_msg; char *s = path; char c; struct stat st; mask = umask(0); if (mode == -1) { umask(mask); mode = (S_IXUSR | S_IXGRP | S_IXOTH | S_IWUSR | S_IWGRP | S_IWOTH | S_IRUSR | S_IRGRP | S_IROTH) & ~mask; } else { umask(mask & ~0300); } do { c = 0; if (flags & FILEUTILS_RECUR) { /* Get the parent. */ /* Bypass leading non-'/'s and then subsequent '/'s. */ while (*s) { if (*s == '/') { do { ++s; } while (*s == '/'); c = *s; /* Save the current char */ *s = 0; /* and replace it with nul. */ break; } ++s; } } if (mkdir(path, 0777) < 0) { /* If we failed for any other reason than the directory * already exists, output a diagnostic and return -1.*/ if (errno != EEXIST || !(flags & FILEUTILS_RECUR) || (stat(path, &st) < 0 || !S_ISDIR(st.st_mode))) { fail_msg = "create"; umask(mask); break; } /* Since the directory exists, don't attempt to change * permissions if it was the full target. Note that * this is not an error conditon. */ if (!c) { umask(mask); return 0; } } if (!c) { /* Done. If necessary, updated perms on the newly * created directory. Failure to update here _is_ * an error.*/ umask(mask); if ((mode != -1) && (chmod(path, mode) < 0)){ fail_msg = "set permissions of"; break; } return 0; } /* Remove any inserted nul from the path (recursive mode). */ *s = c; } while (1); bb_perror_msg("cannot %s directory '%s'", fail_msg, path); return -1;}
开发者ID:Predator-SD,项目名称:Tarixy,代码行数:75,
示例19: mainint main (int argc, char** argv){ UnitTest t (49); // Ensure environment has no influence. unsetenv ("TASKDATA"); unsetenv ("TASKRC"); Directory tmp ("tmp"); tmp.create (); t.ok (tmp.exists (), "tmp dir created."); // Directory (const File&); // Directory (const Path&); Directory d0 (Path ("tmp")); Directory d1 (File ("tmp")); Directory d2 (File (Path ("tmp"))); t.is (d0._data, d1._data, "Directory(std::string) == Directory (File&)"); t.is (d0._data, d2._data, "Directory(std::string) == Directory (File (Path &))"); t.is (d1._data, d2._data, "Directory(File&)) == Directory (File (Path &))"); // Directory (const Directory&); Directory d3 (d2); t.is (d3._data, Directory::cwd () + "/tmp", "Directory (Directory&)"); // Directory (const std::string&); Directory d4 ("tmp/test_directory"); // Directory& operator= (const Directory&); Directory d5 = d4; t.is (d5._data, Directory::cwd () + "/tmp/test_directory", "Directory::operator="); // operator (std::string) const; t.is ((std::string) d3, Directory::cwd () + "/tmp", "Directory::operator (std::string) const"); // virtual bool create (); t.ok (d5.create (), "Directory::create tmp/test_directory"); t.ok (d5.exists (), "Directory::exists tmp/test_directory"); Directory d6 (d5._data + "/dir"); t.ok (d6.create (), "Directory::create tmp/test_directory/dir"); File::create (d5._data + "/f0"); File::create (d6._data + "/f1"); // std::vector <std::string> list (); std::vector <std::string> files = d5.list (); std::sort (files.begin (), files.end ()); t.is ((int)files.size (), 2, "Directory::list 1 file"); t.is (files[0], Directory::cwd () + "/tmp/test_directory/dir", "file[0] is tmp/test_directory/dir"); t.is (files[1], Directory::cwd () + "/tmp/test_directory/f0", "file[1] is tmp/test_directory/f0"); // std::vector <std::string> listRecursive (); files = d5.listRecursive (); std::sort (files.begin (), files.end ()); t.is ((int)files.size (), 2, "Directory::list 1 file"); t.is (files[0], Directory::cwd () + "/tmp/test_directory/dir/f1", "file is tmp/test_directory/dir/f1"); t.is (files[1], Directory::cwd () + "/tmp/test_directory/f0", "file is tmp/test_directory/f0"); // virtual bool remove (); t.ok (File::remove (d5._data + "/f0"), "File::remove tmp/test_directory/f0"); t.ok (File::remove (d6._data + "/f1"), "File::remove tmp/test_directory/dir/f1"); t.ok (d6.remove (), "Directory::remove tmp/test_directory/dir"); t.notok (d6.exists (), "Directory::exists tmp/test_directory/dir - no"); t.ok (d5.remove (), "Directory::remove tmp/test_directory"); t.notok (d5.exists (), "Directory::exists tmp/test_directory - no"); // bool remove (const std::string&); Directory d7 ("tmp/to_be_removed"); t.ok (d7.create (), "Directory::create tmp/to_be_removed"); File::create (d7._data + "/f0"); Directory d8 (d7._data + "/another"); t.ok (d8.create (), "Directory::create tmp/to_be_removed/another"); File::create (d8._data + "/f1"); t.ok (d7.remove (), "Directory::remove tmp/to_be_removed"); t.notok (d7.exists (), "Directory tmp/to_be_removed gone"); // static std::string cwd (); std::string cwd = Directory::cwd (); t.ok (cwd.length () > 0, "Directory::cwd returned a value"); // bool parent (std::string&) const; Directory d9 ("/one/two/three/four.txt"); t.ok (d9.up (), "parent /one/two/three/four.txt --> true"); t.is (d9._data, "/one/two/three", "parent /one/two/three/four.txt --> /one/two/three"); t.ok (d9.up (), "parent /one/two/three --> true"); t.is (d9._data, "/one/two", "parent /one/two/three --> /one/two"); t.ok (d9.up (), "parent /one/two --> true"); t.is (d9._data, "/one", "parent /one/two --> /one"); t.ok (d9.up (), "parent /one --> true"); t.is (d9._data, "/", "parent /one --> /"); t.notok (d9.up (), "parent / --> false"); // Test permissions. umask (0022); Directory d10 ("tmp/dir.perm"); d10.create (0750); t.ok (d10.exists (), "Directory::create perm file exists");//.........这里部分代码省略.........
开发者ID:gerarldlee,项目名称:task,代码行数:101,
示例20: mainint main(int argc, char** argv){ fd_set writeFDs; fd_set readFDs; struct sockaddr_rc addr={0}; char dest[] = "00:12:02:09:04:90"; openlog("sshcounter",LOG_PID,LOG_USER); pid_t pid,sid; pid = fork(); if(pid < 0){ syslog(LOG_INFO,"Fork Failture"); exit(EXIT_FAILURE); } if(pid > 0){ exit(EXIT_SUCCESS); } umask(0); sid = setsid(); if(sid < 0){ syslog(LOG_INFO,"Seting Session ID Failure"); exit(EXIT_FAILURE); } if((chdir("/")) < 0){ syslog(LOG_INFO,"Change Directory Failure"); exit(EXIT_FAILURE); } close(STDIN_FILENO); close(STDOUT_FILENO); close(STDERR_FILENO); int btSocket = socket(AF_BLUETOOTH, SOCK_STREAM|SOCK_NONBLOCK ,BTPROTO_RFCOMM); if(btSocket < 0){ syslog(LOG_INFO,"Socket Creating Failure"); exit(EXIT_FAILURE); } addr.rc_family = AF_BLUETOOTH; addr.rc_channel = (uint8_t)1; str2ba(dest,&addr.rc_bdaddr); // Bluetooth Device Search int max_rsp,num_rsp,len,flags,dev_id,i; char buf[1024] = {0}; int found = 0; inquiry_info *ii = NULL; len = 8; max_rsp = 255; flags = IREQ_CACHE_FLUSH; dev_id = hci_get_route(NULL); ii = (inquiry_info*)malloc(max_rsp * sizeof(inquiry_info)); while(1){ // Quiry bluetooth device around num_rsp = hci_inquiry(dev_id,len,max_rsp,NULL,&ii,flags); for(i = 0; i < num_rsp; i++){ ba2str(&(ii+i)->bdaddr,buf); // If found, set found to true and break if(strcmp(dest,buf) == 0){ found = 1; break; } } // If found, break out query loop and connect if(found){ syslog(LOG_INFO,"Bluetooth Device Found"); break; } } int rc; // Since the socket is nonblocking, using select() int status = connect(btSocket,(struct sockaddr*)&addr,sizeof(addr)); if(errno == EINPROGRESS){ for(;;){ FD_ZERO(&writeFDs); FD_ZERO(&readFDs); FD_SET(btSocket,&writeFDs); FD_SET(btSocket,&readFDs); rc = select(btSocket+1,&readFDs,&writeFDs,NULL,NULL); if(FD_ISSET(btSocket,&writeFDs)){ if(FD_ISSET(btSocket,&readFDs)){ sleep(5); status = connect(btSocket,(struct sockaddr*)&addr,sizeof(addr)); continue; } else{ break; } } } } syslog(LOG_INFO,"Bluetooth Device Connected"); char numConnections; while(1){ FILE* file = popen("netstat -an | grep -E '//:22[ //t]+' | grep ESTABLISHED | wc -l","r"); if(file == NULL){ syslog(LOG_INFO,"POPEN Failure"); exit(EXIT_FAILURE); } fscanf(file, "%c",&numConnections); fclose(file); write(btSocket, &numConnections, 1); sleep(1);//.........这里部分代码省略.........
开发者ID:penghou620,项目名称:sshcounter,代码行数:101,
示例21: lo_export/* * lo_export - * exports an (inversion) large object. */Datumlo_export(PG_FUNCTION_ARGS){ Oid lobjId = PG_GETARG_OID(0); text *filename = PG_GETARG_TEXT_PP(1); int fd; int nbytes, tmp; char buf[BUFSIZE]; char fnamebuf[MAXPGPATH]; LargeObjectDesc *lobj; mode_t oumask;#ifndef ALLOW_DANGEROUS_LO_FUNCTIONS if (!superuser()) ereport(ERROR, (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), errmsg("must be superuser to use server-side lo_export()"), errhint("Anyone can use the client-side lo_export() provided by libpq.")));#endif CreateFSContext(); /* * open the inversion object (no need to test for failure) */ lobj = inv_open(lobjId, INV_READ, fscxt); /* * open the file to be written to * * Note: we reduce backend's normal 077 umask to the slightly friendlier * 022. This code used to drop it all the way to 0, but creating * world-writable export files doesn't seem wise. */ text_to_cstring_buffer(filename, fnamebuf, sizeof(fnamebuf)); oumask = umask(S_IWGRP | S_IWOTH); fd = OpenTransientFile(fnamebuf, O_CREAT | O_WRONLY | O_TRUNC | PG_BINARY, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); umask(oumask); if (fd < 0) ereport(ERROR, (errcode_for_file_access(), errmsg("could not create server file /"%s/": %m", fnamebuf))); /* * read in from the inversion file and write to the filesystem */ while ((nbytes = inv_read(lobj, buf, BUFSIZE)) > 0) { tmp = write(fd, buf, nbytes); if (tmp != nbytes) ereport(ERROR, (errcode_for_file_access(), errmsg("could not write server file /"%s/": %m", fnamebuf))); } CloseTransientFile(fd); inv_close(lobj); PG_RETURN_INT32(1);}
开发者ID:kaigai,项目名称:sepgsql,代码行数:68,
示例22: main/** * The main() function of ngIRCd. * * Here all starts: this function is called by the operating system loader, * it is the first portion of code executed of ngIRCd. * * @param argc The number of arguments passed to ngIRCd on the command line. * @param argv An array containing all the arguments passed to ngIRCd. * @return Global exit code of ngIRCd, zero on success. */GLOBAL intmain(int argc, const char *argv[]){ bool ok, configtest = false; bool NGIRCd_NoDaemon = false; int i; size_t n;#if defined(DEBUG) && defined(HAVE_MTRACE) /* enable GNU libc memory tracing when running in debug mode * and functionality available */ mtrace();#endif umask(0077); NGIRCd_SignalQuit = NGIRCd_SignalRestart = false; NGIRCd_Passive = false;#ifdef DEBUG NGIRCd_Debug = false;#endif#ifdef SNIFFER NGIRCd_Sniffer = false;#endif strlcpy(NGIRCd_ConfFile, SYSCONFDIR, sizeof(NGIRCd_ConfFile)); strlcat(NGIRCd_ConfFile, CONFIG_FILE, sizeof(NGIRCd_ConfFile)); Fill_Version(); /* parse conmmand line */ for (i = 1; i < argc; i++) { ok = false; if (argv[i][0] == '-' && argv[i][1] == '-') { /* long option */ if (strcmp(argv[i], "--config") == 0) { if (i + 1 < argc) { /* Ok, there's an parameter left */ strlcpy(NGIRCd_ConfFile, argv[i+1], sizeof(NGIRCd_ConfFile)); /* next parameter */ i++; ok = true; } } if (strcmp(argv[i], "--configtest") == 0) { configtest = true; ok = true; }#ifdef DEBUG if (strcmp(argv[i], "--debug") == 0) { NGIRCd_Debug = true; ok = true; }#endif if (strcmp(argv[i], "--help") == 0) { Show_Version(); puts(""); Show_Help( ); puts( "" ); exit(1); } if (strcmp(argv[i], "--nodaemon") == 0) { NGIRCd_NoDaemon = true; ok = true; } if (strcmp(argv[i], "--passive") == 0) { NGIRCd_Passive = true; ok = true; }#ifdef SNIFFER if (strcmp(argv[i], "--sniffer") == 0) { NGIRCd_Sniffer = true; ok = true; }#endif if (strcmp(argv[i], "--version") == 0) { Show_Version(); exit(1); } } else if(argv[i][0] == '-' && argv[i][1] != '-') { /* short option */ for (n = 1; n < strlen(argv[i]); n++) { ok = false;#ifdef DEBUG if (argv[i][n] == 'd') { NGIRCd_Debug = true; ok = true; }#endif if (argv[i][n] == 'f') { if (!argv[i][n+1] && i+1 < argc) { /* Ok, next character is a blank *///.........这里部分代码省略.........
开发者ID:LucentW,项目名称:ngircd,代码行数:101,
示例23: daemonizevoid daemonize(const char *cmd){ struct rlimit rlim; int fd0, fd1, fd2; int i; pid_t pid; struct sigaction sa; if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) { printf("%s: getrlimit error: %s", cmd, strerror(errno)); exit(1); } umask(0); if ((pid = fork()) < 0) { printf("%s: fork error: %s", cmd, strerror(errno)); exit(1); } else if (pid != 0) { /* parent */ exit(0); } setsid(); /* child */ sa.sa_handler = SIG_IGN; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; if (sigaction(SIGHUP, &sa, NULL) < 0) { printf("%s: sigaction SIGHUP error: %s", cmd, strerror(errno)); exit(1); } if ((pid = fork()) < 0) { printf("%s: fork error: %s", cmd, strerror(errno)); exit(1); } else if (pid != 0) { /* parent again */ exit(0); } if (chdir("/") < 0) { printf("%s: chdir to / error: %s", cmd, strerror(errno)); exit(1); } /* child */ if (rlim.rlim_max == RLIM_INFINITY) rlim.rlim_max = 1024; for (i = 0; i < rlim.rlim_max; ++i) close(i); fd0 = open("/dev/null", O_RDWR); fd1 = dup(0); fd2 = dup(0); openlog(cmd, LOG_CONS, LOG_DAEMON); if (fd0 != 0 || fd1 != 1 || fd2 != 2) { syslog(LOG_ERR, "unexpected file descriptors: %d, %d, %d", fd0, fd1, fd2); exit(1); }}
开发者ID:forkhope,项目名称:apue2,代码行数:62,
示例24: main//.........这里部分代码省略......... fp = fopen("/dev/null", "w+"); if (fileno(fp) != STDIN_FILENO) { msg_out(crit, "fopen: %m"); exit(1); } if (dup2(STDIN_FILENO, STDOUT_FILENO) == -1) { msg_out(crit, "dup2-1: %m"); exit(1); } if (dup2(STDIN_FILENO, STDERR_FILENO) == -1) { msg_out(crit, "dup2-2: %m"); exit(1); } switch(fork()) { case -1: msg_out(crit, "fork: %m"); exit(1); case 0: /* child */ pid = setsid(); if (pid == -1) { msg_out(crit, "setsid: %m"); exit(1); } break; default: /* parent */ exit(0); } } master_pid = getpid(); umask(S_IWGRP|S_IWOTH); if ((fp = fopen(pidfile, "w")) != NULL) { fprintf(fp, "%u/n", (unsigned)master_pid); fchown(fileno(fp), PROCUID, PROCGID); fclose(fp); } else { msg_out(warn, "cannot open pidfile %s", pidfile); } setsignal(SIGHUP, reload); if (fg) setsignal(SIGINT, cleanup); else setsignal(SIGINT, SIG_IGN); setsignal(SIGQUIT, SIG_IGN); setsignal(SIGILL, SIG_IGN); setsignal(SIGTRAP, SIG_IGN); setsignal(SIGABRT, SIG_IGN);#ifdef SIGEMT setsignal(SIGEMT, SIG_IGN);#endif setsignal(SIGSYS, SIG_IGN); setsignal(SIGPIPE, SIG_IGN); setsignal(SIGALRM, SIG_IGN); setsignal(SIGTERM, cleanup); setsignal(SIGUSR1, SIG_IGN); setsignal(SIGUSR2, SIG_IGN);#ifdef SIGPOLL setsignal(SIGPOLL, SIG_IGN);#endif setsignal(SIGVTALRM, SIG_IGN); setsignal(SIGPROF, SIG_IGN); setsignal(SIGXCPU, SIG_IGN);
开发者ID:LazyZhu,项目名称:srelay,代码行数:67,
示例25: mailmbox_expunge_no_lockint mailmbox_expunge_no_lock(struct mailmbox_folder * folder){ char tmp_file[PATH_MAX]; int r; int res; int dest_fd; size_t size; mode_t old_mask; if (folder->mb_read_only) return MAILMBOX_ERROR_READONLY; if (((folder->mb_written_uid >= folder->mb_max_uid) || folder->mb_no_uid) && (!folder->mb_changed)) { /* no need to expunge */ return MAILMBOX_NO_ERROR; } snprintf(tmp_file, PATH_MAX, "%sXXXXXX", folder->mb_filename); old_mask = umask(0077); dest_fd = mkstemp(tmp_file); umask(old_mask); if (dest_fd < 0) { /* fallback to tmp dir */ snprintf(tmp_file, PATH_MAX, TMPDIR "/etpan-unsafe-XXXXXX"); old_mask = umask(0077); dest_fd = mkstemp(tmp_file); umask(old_mask); if (dest_fd < 0) { res = MAILMBOX_ERROR_FILE; goto err; } } r = mailmbox_expunge_to_file_no_lock(tmp_file, dest_fd, folder, &size); if (r != MAILMBOX_NO_ERROR) { res = r; goto unlink; } close(dest_fd); r = rename(tmp_file, folder->mb_filename); if (r < 0) { mailmbox_unmap(folder); mailmbox_close(folder); /* fallback on copy to old file */ r = copy_to_old_file(tmp_file, folder->mb_filename, size); if (r != MAILMBOX_NO_ERROR) { res = r; goto err; } unlink(tmp_file); } else { mailmbox_unmap(folder); mailmbox_close(folder); } r = mailmbox_open(folder); if (r != MAILMBOX_NO_ERROR) { res = r; goto err; } r = mailmbox_map(folder); if (r != MAILMBOX_NO_ERROR) { res = r; goto err; } r = mailmbox_parse(folder); if (r != MAILMBOX_NO_ERROR) { res = r; goto err; } mailmbox_timestamp(folder); folder->mb_changed = FALSE; folder->mb_deleted_count = 0; return MAILMBOX_NO_ERROR; unlink: close(dest_fd); unlink(tmp_file); err: return res;}
开发者ID:dinhviethoa,项目名称:libetpan,代码行数:98,
示例26: ds_daemonint ds_daemon(http_conf * conf, int t){ int uid = getuid(); int gid = getgid(); int status = 0; if(conf->user && strlen(conf->user)) { struct passwd * pw = getpwnam(conf->user); if(!pw) { printf(" user[%s] no found/n", conf->user); exit(0); } uid = pw->pw_uid; gid = pw->pw_gid; printf("/n user:%s/n", conf->user); } if(t == 0 ) { ds_init_daemon(conf); } if( t == 0 || t == 1) { ds_init_children(conf); //ds_pid = getpid(); if(setsid() == -1) { //setsid创建一个新会话 printf("setsid() failed!" DS_LINEEND); exit(0); } umask(0); setuid(uid); setgid(gid); ds_init(conf); } /*if( t == 2) { conf->work_mode = FORK_PROCESS_WORK_HTTP_MODE; }*/ if(t == 2) { //使用两个pipe 完成accept 和cgi进程的通信,pipe 0read, 1write int pipHttp[2], pipCgi[2]; pipe(pipHttp); pipe(pipCgi); int forkCgiPid = fork(); if(forkCgiPid == 0) { conf->child_pip.in = pipCgi[0]; conf->child_pip.out = pipHttp[1]; close(pipHttp[0]); close(pipCgi[1]); conf->work_mode = FORK_PROCESS_WORK_CGI_MODE; } else { conf->child_pip.in = pipHttp[0]; conf->child_pip.out = pipCgi[1]; close(pipHttp[1]); close(pipCgi[0]); conf->work_mode = FORK_PROCESS_WORK_HTTP_MODE; } } return OK;}
开发者ID:rentiansheng,项目名称:devSync,代码行数:70,
示例27: syslogd_mainextern int syslogd_main(int argc, char **argv){ int opt; int doFork = TRUE; char *p; /* do normal option parsing */ while ((opt = getopt(argc, argv, "m:nO:s:Sb:R:LC::")) > 0) { switch (opt) { case 'm': MarkInterval = atoi(optarg) * 60; break; case 'n': doFork = FALSE; break; case 'O': logFilePath = optarg; break;#ifdef CONFIG_FEATURE_ROTATE_LOGFILE case 's': logFileSize = atoi(optarg) * 1024; break; case 'b': logFileRotate = atoi(optarg); if( logFileRotate > 99 ) logFileRotate = 99; break;#endif#ifdef CONFIG_FEATURE_REMOTE_LOG case 'R': RemoteHost = bb_xstrdup(optarg); if ((p = strchr(RemoteHost, ':'))) { RemotePort = atoi(p + 1); *p = '/0'; } doRemoteLog = TRUE; break; case 'L': local_logging = TRUE; break;#endif#ifdef CONFIG_FEATURE_IPC_SYSLOG case 'C': if (optarg) { int buf_size = atoi(optarg); if (buf_size >= 4) { shm_size = buf_size * 1024; } } circular_logging = TRUE; break;#endif case 'S': small = true; break; default: bb_show_usage(); } }#ifdef CONFIG_FEATURE_REMOTE_LOG /* If they have not specified remote logging, then log locally */ if (doRemoteLog == FALSE) local_logging = TRUE;#endif /* Store away localhost's name before the fork */ gethostname(LocalHostName, sizeof(LocalHostName)); if ((p = strchr(LocalHostName, '.'))) { *p = '/0'; } umask(0); if (doFork == TRUE) {#if defined(__uClinux__) vfork_daemon_rexec(0, 1, argc, argv, "-n");#else /* __uClinux__ */ if(daemon(0, 1) < 0) bb_perror_msg_and_die("daemon");#endif /* __uClinux__ */ } doSyslogd(); return EXIT_SUCCESS;}
开发者ID:K0T0LI,项目名称:busybox,代码行数:88,
示例28: mainintmain(int argc, char *argv[]){ /* Check to see if the user is running us as root, which is a nono */ if(geteuid() == 0) { fprintf(stderr, "Don't run ircd as root!!!/n"); return -1; } /* * save server boot time right away, so getrusage works correctly */ set_time(); /* * Setup corefile size immediately after boot -kre */ setup_corefile(); /* * set initialVMTop before we allocate any memory */ initialVMTop = get_vm_top(); ServerRunning = 0; /* It ain't random, but it ought to be a little harder to guess */ srand(SystemTime.tv_sec ^ (SystemTime.tv_usec | (getpid() << 20))); memset(&me, 0, sizeof(me)); memset(&meLocalUser, 0, sizeof(meLocalUser)); me.localClient = &meLocalUser; /* Make sure all lists are zeroed */ memset(&unknown_list, 0, sizeof(unknown_list)); memset(&lclient_list, 0, sizeof(lclient_list)); memset(&serv_list, 0, sizeof(serv_list)); memset(&global_serv_list, 0, sizeof(global_serv_list)); memset(&oper_list, 0, sizeof(oper_list)); dlinkAddTail(&me, &me.node, &global_client_list); memset((void *) &Count, 0, sizeof(Count)); memset((void *) &ServerInfo, 0, sizeof(ServerInfo)); memset((void *) &AdminInfo, 0, sizeof(AdminInfo)); /* Initialise the channel capability usage counts... */ init_chcap_usage_counts(); ConfigFileEntry.dpath = DPATH; ConfigFileEntry.configfile = CPATH; /* Server configuration file */ ConfigFileEntry.klinefile = KPATH; /* Server kline file */ ConfigFileEntry.dlinefile = DLPATH; /* dline file */ ConfigFileEntry.xlinefile = XPATH; ConfigFileEntry.resvfile = RESVPATH; ConfigFileEntry.connect_timeout = 30; /* Default to 30 */ myargv = argv; umask(077); /* better safe than sorry --SRB */ parseargs(&argc, &argv, myopts); if(printVersion) { printf("ircd: version %s/n", ircd_version); exit(EXIT_SUCCESS); } if(chdir(ConfigFileEntry.dpath)) { fprintf(stderr, "Unable to chdir to %s: %s/n", ConfigFileEntry.dpath, strerror(errno)); exit(EXIT_FAILURE); } setup_signals();#ifdef __CYGWIN__ server_state_foreground = 1;#endif if (testing_conf) server_state_foreground = 1; /* We need this to initialise the fd array before anything else */ fdlist_init(); if(!server_state_foreground) { comm_close_all(); } /* Check if there is pidfile and daemon already running */ if(!testing_conf) { check_pidfile(pidFileName); if(!server_state_foreground) make_daemon(); else print_startup(getpid()); } init_netio(); /* This needs to be setup early ! -- adrian *///.........这里部分代码省略.........
开发者ID:Cloudxtreme,项目名称:ircd-ratbox,代码行数:101,
示例29: pw_init/* * Initialize statics and set limits, signals & umask to try to avoid * interruptions, crashes etc. that might expose passord data. */intpw_init(const char *dir, const char *master){#if 0 struct rlimit rlim;#endif if (dir == NULL) { strcpy(passwd_dir, _PATH_ETC); } else { if (strlen(dir) >= sizeof(passwd_dir)) { errno = ENAMETOOLONG; return (-1); } strcpy(passwd_dir, dir); } if (master == NULL) { if (dir == NULL) { strcpy(masterpasswd, _PATH_MASTERPASSWD); } else if (snprintf(masterpasswd, sizeof(masterpasswd), "%s/%s", passwd_dir, _MASTERPASSWD) > (int)sizeof(masterpasswd)) { errno = ENAMETOOLONG; return (-1); } } else { if (strlen(master) >= sizeof(masterpasswd)) { errno = ENAMETOOLONG; return (-1); } strcpy(masterpasswd, master); } /* * The code that follows is extremely disruptive to the calling * process, and is therefore disabled until someone can conceive * of a realistic scenario where it would fend off a compromise. * Race conditions concerning the temporary files can be guarded * against in other ways than masking signals (by checking stat(2) * results after creation). */#if 0 /* Unlimited resource limits. */ rlim.rlim_cur = rlim.rlim_max = RLIM_INFINITY; (void)setrlimit(RLIMIT_CPU, &rlim); (void)setrlimit(RLIMIT_FSIZE, &rlim); (void)setrlimit(RLIMIT_STACK, &rlim); (void)setrlimit(RLIMIT_DATA, &rlim); (void)setrlimit(RLIMIT_RSS, &rlim); /* Don't drop core (not really necessary, but GP's). */ rlim.rlim_cur = rlim.rlim_max = 0; (void)setrlimit(RLIMIT_CORE, &rlim); /* Turn off signals. */ (void)signal(SIGALRM, SIG_IGN); (void)signal(SIGHUP, SIG_IGN); (void)signal(SIGINT, SIG_IGN); (void)signal(SIGPIPE, SIG_IGN); (void)signal(SIGQUIT, SIG_IGN); (void)signal(SIGTERM, SIG_IGN); (void)signal(SIGCONT, pw_cont); /* Create with exact permissions. */ (void)umask(0);#endif initialized = 1; return (0);}
开发者ID:hmatyschok,项目名称:MeshBSD,代码行数:73,
注:本文中的umask函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ umount函数代码示例 C++ umalloc函数代码示例 |