void cleanup() { remove_hook(); if (!isattached) killtask(); free_symbols(); close_all_elfhandles(); stabs_free_stabs(); hex_close_window(); breakpoints_close_window(); modules_close_window(); main_close_window(); arexx_close_port(); IExec->FreeSysObject(ASOT_PORT, AppPort); pipe_cleanup(); variables_cleanup(); console_cleanup(); stacktrace_cleanup(); source_cleanup(); disassembler_cleanup(); sourcelist_cleanup(); freemem_free_hook(main_freemem_hook); char sysstring[1024] = ""; sprintf(sysstring, "setenv DB101_LASTDIR SAVE \"%s\"", lastdir); IDOS->SystemTags(sysstring, TAG_END); }
void fd_exec(char *command_line, int *toprog, int *fromprog) { PROCESS_INFORMATION piProcInfo; STARTUPINFO siStartInfo; SECURITY_ATTRIBUTES saAttr; int inpipes[2], outpipes[2]; HANDLE old_handles[2]; siStartInfo.cb = sizeof(STARTUPINFO); siStartInfo.lpReserved = NULL; siStartInfo.lpReserved2 = NULL; siStartInfo.cbReserved2 = 0; siStartInfo.lpDesktop = NULL; /* pipe_setup initializes the rest of siStartInfo */ saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); saAttr.bInheritHandle = TRUE; saAttr.lpSecurityDescriptor = NULL; pipe_setup(&siStartInfo, inpipes, outpipes, old_handles); if (! CreateProcess(NULL, command_line, NULL, NULL, TRUE, 0, NULL, NULL, &siStartInfo, &piProcInfo)) { DWORD debug_info = GetLastError(); *toprog = *fromprog = -1; } else { *toprog = inpipes[1]; /* fd we can write to */ *fromprog = outpipes[0]; /* fd we can read from */ } pipe_cleanup(inpipes, outpipes, old_handles); }
static void fd_exec(obj_t self, struct thread *thread, obj_t *args) { obj_t *oldargs; oldargs = args - 1; thread->sp = args + 1; { PROCESS_INFORMATION piProcInfo; STARTUPINFO siStartInfo; SECURITY_ATTRIBUTES saAttr; int inpipes[2], outpipes[2]; HANDLE old_handles[2]; const char *command_line = string_chars(args[0]); siStartInfo.cb = sizeof(STARTUPINFO); siStartInfo.lpReserved = NULL; siStartInfo.lpReserved2 = NULL; siStartInfo.cbReserved2 = 0; siStartInfo.lpDesktop = NULL; /* pipe_setup initializes the rest of siStartInfo */ saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); saAttr.bInheritHandle = true; saAttr.lpSecurityDescriptor = NULL; pipe_setup(&siStartInfo, inpipes, outpipes, old_handles); if (! CreateProcess(NULL, command_line, NULL, NULL, true, 0, NULL, NULL, &siStartInfo, &piProcInfo)) { DWORD debug_info = GetLastError(); oldargs[0] = obj_False; oldargs[1] = obj_False; } else { oldargs[0] = make_fixnum(inpipes[1]); /* fd we can write to */ oldargs[1] = make_fixnum(outpipes[0]); /* fd we can read from */ setup_input_checker(outpipes[0]); } pipe_cleanup(inpipes, outpipes, old_handles); } do_return(thread, oldargs, oldargs); }
int pipe_setup(struct media_file_info *mfi) { struct stat sb; if (!mfi->path) { DPRINTF(E_LOG, L_PLAYER, "Path to pipe is NULL\n"); return -1; } DPRINTF(E_DBG, L_PLAYER, "Setting up pipe: %s\n", mfi->path); if (lstat(mfi->path, &sb) < 0) { DPRINTF(E_LOG, L_PLAYER, "Could not lstat() '%s': %s\n", mfi->path, strerror(errno)); return -1; } if (!S_ISFIFO(sb.st_mode)) { DPRINTF(E_LOG, L_PLAYER, "Source type is pipe, but path is not a fifo: %s\n", mfi->path); return -1; } pipe_cleanup(); g_fd = open(mfi->path, O_RDONLY | O_NONBLOCK); if (g_fd < 0) { DPRINTF(E_LOG, L_PLAYER, "Could not open pipe for reading '%s': %s\n", mfi->path, strerror(errno)); return -1; } g_buf = (uint16_t *)malloc(PIPE_BUFFER_SIZE); if (!g_buf) { DPRINTF(E_LOG, L_PLAYER, "Out of memory for buffer\n"); return -1; } return 1; }
/** * @brief Entry point for the program * * Parses arguments for program mode and responds appropriately. * * Preconditions: Proper arguments have been supplied * * Postconditions: * * @param argc Number of arguments supplied * @param argv List of arguments supplied * @return Exit status */ int main(int argc, char **argv) { struct sigaction sigact; struct pipe_res pipe_res; struct shmem_res shmem_res; struct sock_res sock_res; char mode; if (argc < ARGC_MIN) { usage(); } memset(&sigact, 0, sizeof(struct sigaction)); sigact.sa_handler = handle_signal; if (sigaction(SIGQUIT, &sigact, NULL) == -1) { perror("Could not set SIGQUIT handler"); } if (sigaction(SIGHUP, &sigact, NULL) == -1) { perror("Could not set SIGHUP handler"); } if (sigaction(SIGINT, &sigact, NULL) == -1) { perror("Could not set SIGINT handler"); } sigact.sa_handler = SIG_IGN; if (sigaction(SIGPIPE, &sigact, NULL) == -1) { perror("Could not set SIGPIPE handler"); } mode = argv[MODE_ARG][0]; // Only need the first character switch (mode) { case 'p': // Pipe stuff if (pipe_init(argc, argv, &pipe_res) == false) { collect_computes(&pipe_res); exit(EXIT_FAILURE); } pipe_report(&pipe_res); pipe_cleanup(&pipe_res); break; case 'm': // Shmem stuff if (shmem_init(argc, argv, &shmem_res) == false) { exit(EXIT_FAILURE); } while (1) { // Loop until signaled to shut down if (exit_status != EXIT_SUCCESS) { fputs("\r", stderr); break; } } shmem_cleanup(&shmem_res); break; case 's': // Socket stuff if (sock_init(argc, argv, &sock_res) == false) { exit(EXIT_FAILURE); } sock_report(&sock_res); sock_cleanup(&sock_res); break; default: usage(); break; } exit(EXIT_SUCCESS); }