| 64 | |
| 65 | |
| 66 | pid_t UTIL_start_process(const char* process, char** argv, const char* prog_name) |
| 67 | { |
| 68 | /************************************** |
| 69 | * |
| 70 | * U T I L _ s t a r t _ p r o c e s s |
| 71 | * |
| 72 | ************************************** |
| 73 | * |
| 74 | * Functional description |
| 75 | * |
| 76 | * This function is used to create the specified process, |
| 77 | * |
| 78 | * Returns Codes: |
| 79 | * -1 Process spawn failed. |
| 80 | * pid Successful creation. PID is returned. |
| 81 | * |
| 82 | * Note: Make sure that the argument list ends with a null |
| 83 | * and the first argument is large enough to hold the complete |
| 84 | * expanded process name. (MAXPATHLEN recommended) |
| 85 | * |
| 86 | **************************************/ |
| 87 | fb_assert(process != NULL); |
| 88 | fb_assert(argv != NULL); |
| 89 | |
| 90 | // prepend Firebird home directory to the program name |
| 91 | Firebird::PathName string = fb_utils::getPrefix(Firebird::IConfigManager::DIR_SBIN, process); |
| 92 | |
| 93 | if (prog_name) { |
| 94 | gds__log("%s: guardian starting %s\n", prog_name, string.c_str()); |
| 95 | } |
| 96 | |
| 97 | // add place in argv for visibility to "ps" |
| 98 | strcpy(argv[0], string.c_str()); |
| 99 | #if (defined SOLARIS) |
| 100 | pid_t pid = fork1(); |
| 101 | if (!pid) |
| 102 | { |
| 103 | if (execv(string.c_str(), argv) == -1) { |
| 104 | //ib_fprintf(ib_stderr, "Could not create child process %s with args %s\n", string, argv); |
| 105 | } |
| 106 | exit(FINI_ERROR); |
| 107 | } |
| 108 | |
| 109 | #else |
| 110 | |
| 111 | pid_t pid = vfork(); |
| 112 | if (!pid) |
| 113 | { |
| 114 | execv(string.c_str(), argv); |
| 115 | _exit(FINI_ERROR); |
| 116 | } |
| 117 | #endif |
| 118 | return (pid); |
| 119 | } |
| 120 | |
| 121 | |
| 122 | int UTIL_wait_for_child(pid_t child_pid, const volatile sig_atomic_t& shutting_down) |
no test coverage detected