unsigned WINAPI run_process(void * pParam) { PROCESS_INFORMATION pi; STARTUPINFOW si; WCHAR wcmd[VALUE_LEN+1] = {0}; WCHAR wdirectory[VALUE_LEN+1] = {0}; DWORD dwCreat = 0; int flags = get_parameters(wdirectory, wcmd, VALUE_LEN); if (flags<0) { return (0); } /* 如果是预启动,直接返回 */ if ( parse_shcommand() ) { return (0); } if ( GetLastError() == ERROR_ALREADY_EXISTS ) { return (0); } if ( wcslen(wcmd)>0 && !search_process(wcmd,0) ) { fzero(&si,sizeof(si)); si.cb = sizeof(si); si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = SW_MINIMIZE; if (!flags) { si.wShowWindow = SW_HIDE; dwCreat |= CREATE_NEW_PROCESS_GROUP; } if(!CreateProcessW(NULL, (LPWSTR)wcmd, NULL, NULL, FALSE, dwCreat, NULL, (LPCWSTR)wdirectory, &si,&pi)) { #ifdef _LOGDEBUG logmsg("CreateProcessW error %lu\n",GetLastError()); #endif return (0); } g_handle[0] = pi.hProcess; CloseHandle(pi.hThread); if ( pi.dwProcessId >4 && (SleepEx(6000,FALSE) == 0) ) { search_process(NULL, pi.dwProcessId); } } return (1); }
int do_mon(void) { struct mon *v; checkupgrade(); checknas(); #ifndef HAVE_RT2880 softcontrol_wlan_led(); #endif for (v = mons; v < &mons[sizeof(mons) / sizeof(struct mon)]; v++) { if (v->name == NULL) break; if (v->nvvalue && v->nvmatch) { if (!nvram_match(v->nvvalue, v->nvmatch)) continue; // service not enabled. no need to check } printf("checking %s\n", v->name); if (v->type == M_WAN) if (!check_wan_link(0)) { printf("process is wan, but wan is not up\n"); continue; } if (!search_process(v->name, v->count)) { printf("Maybe %s had died, we need to re-exec it\n", v->name); sysprintf("stopservice %s", v->name); killall(v->name, SIGKILL); sysprintf("startservice_f %s", v->name); } printf("checking for %s done\n", v->name); } return 1; }
void search_refresh (void) { if (searchwin && gtk_widget_get_visible (searchwin)) { GtkEntry *entry = GTK_ENTRY (lookup_widget (searchwin, "searchentry")); const gchar *text = gtk_entry_get_text (entry); search_process (text); GtkWidget *pl = lookup_widget (searchwin, "searchlist"); ddb_listview_refresh (DDB_LISTVIEW (pl), DDB_REFRESH_VSCROLL | DDB_REFRESH_LIST | DDB_LIST_CHANGED); } }
void search_refresh (void) { if (searchwin && gtk_widget_get_visible (searchwin)) { GtkEntry *entry = GTK_ENTRY (lookup_widget (searchwin, "searchentry")); const gchar *text = gtk_entry_get_text (entry); search_process (text); GtkWidget *pl = lookup_widget (searchwin, "searchlist"); ddb_listview_refresh (DDB_LISTVIEW (pl), DDB_REFRESH_VSCROLL | DDB_REFRESH_LIST | DDB_LIST_CHANGED); deadbeef->sendmessage (DB_EV_FOCUS_SELECTION, (uintptr_t)pl, PL_MAIN, 0); } }
HANDLE WINAPI search_process(LPCWSTR lpstr, DWORD m_parent) { BOOL b_more; PROCESSENTRY32W pe32; HANDLE hSnapshot = INVALID_HANDLE_VALUE; DWORD chi_pid[PROCESS_NUM] = {0}; HANDLE m_handle = NULL; volatile int i = 1; static int h_num = 1; hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0); if( hSnapshot == INVALID_HANDLE_VALUE ) { #ifdef _LOGDEBUG logmsg("CreateToolhelp32Snapshot (of processes) error %lu\n",GetLastError() ); #endif return m_handle; } chi_pid[0] = m_parent; pe32.dwSize=sizeof(pe32); b_more = Process32FirstW(hSnapshot,&pe32); while (b_more) { if ( m_parent == pe32.th32ParentProcessID ) { chi_pid[i++] = pe32.th32ProcessID; if (i>=PROCESS_NUM) { break; } } if ( lpstr && pe32.th32ParentProcessID>4 && StrStrIW((LPWSTR)lpstr,(LPCWSTR)pe32.szExeFile) ) { m_handle = (HANDLE)pe32.th32ProcessID; break; } b_more = Process32NextW(hSnapshot,&pe32); } CloseHandle(hSnapshot); if ( !m_handle && chi_pid[0] ) { for ( i=1 ; i<PROCESS_NUM&&h_num<PROCESS_NUM; ++i ) { HANDLE tmp = OpenProcess(PROCESS_TERMINATE, FALSE, chi_pid[i]); if ( NULL != tmp ) { g_handle[h_num++] = tmp; search_process(NULL, chi_pid[i]); } } } return m_handle; }
static gboolean refresh_cb (gpointer p) { refresh_source_id = 0; DdbListview *listview = playlist_visible(); if (listview) { ddb_playlist_t *plt = deadbeef->plt_get_curr (); if (plt) { search_process (listview, plt); deadbeef->plt_unref (plt); } } return FALSE; }
static int process_arg(int *arg, char **argv, int argc) { int prev_arg = *arg; char *current_arg = argv[*arg]; int current_process = search_process(current_arg); if (current_process == -1) return poclcc_error("Unknown argument!\n"); else { poclcc_option * current_option = &options[current_process]; int num_args_read = current_option->num_args_read; *arg = prev_arg + num_args_read; return current_option->fct(prev_arg + 1, argv, argc); } }
void on_searchentry_changed (GtkEditable *editable, gpointer user_data) { DdbListview *listview = playlist_visible(); if (listview) { ddb_playlist_t *plt = deadbeef->plt_get_curr (); if (plt) { deadbeef->plt_deselect_all (plt); search_process (listview, plt); for (DB_playItem_t *it = deadbeef->plt_get_first (plt, PL_SEARCH); it; it = next_playitem (it)) { deadbeef->pl_set_selected (it, 1); } deadbeef->plt_unref (plt); } deadbeef->sendmessage (DB_EV_PLAYLISTCHANGED, 0, DDB_PLAYLIST_CHANGE_SELECTION, 0); DB_playItem_t *head = deadbeef->pl_get_first (PL_SEARCH); if (head) { ddb_event_track_t *event = (ddb_event_track_t *)deadbeef->event_alloc(DB_EV_CURSOR_MOVED); event->track = head; deadbeef->event_send ((ddb_event_t *)event, PL_SEARCH, 0); } } }
int main(int argc, char **argv) { //MANAGEMENT OF ARGUMENTS options_help = options; int arg_num=1; if (argc < 2) return poclcc_error("Invalid argument!\n"); while (arg_num < argc-1) if (process_arg(&arg_num, argv, argc)) return -1; if (arg_num >= argc && list_devices) list_devices_only = 1; else if (arg_num >= argc) poclcc_error("Invalid arguments!\n"); else { int current_process = search_process(argv[arg_num]); if (current_process == -1 && process_kernel_file(arg_num, argv, argc)) return -1; else if (current_process != -1) { process_arg(&arg_num, argv, argc); list_devices_only = 1; } } //OPENCL STUFF cl_platform_id cpPlatform; cl_device_id device_ids[NUM_OF_DEVICE_ID]; cl_context context; cl_program program; cl_int err; cl_uint num_devices, i; CHECK_CL_ERROR(clGetPlatformIDs(1, &cpPlatform, NULL)); CHECK_CL_ERROR(clGetDeviceIDs(cpPlatform, opencl_device, NUM_OF_DEVICE_ID, device_ids, &num_devices)); if (opencl_device_id >= num_devices) return poclcc_error("Invalid opencl device_id!\n"); if (list_devices) { context = clCreateContext(0, num_devices, device_ids, NULL, NULL, &err); CHECK_CL_ERROR2(err, clCreateContext); printf("LIST OF DEVICES:\n"); for (i=0; i<num_devices; i++) { char str[DEVICE_INFO_MAX_LENGTH]; CHECK_CL_ERROR(clGetDeviceInfo(device_ids[i], CL_DEVICE_VENDOR, DEVICE_INFO_MAX_LENGTH, str, NULL)); printf("%i: %s --- ", i, str); CHECK_CL_ERROR(clGetDeviceInfo(device_ids[i], CL_DEVICE_NAME, DEVICE_INFO_MAX_LENGTH, str, NULL)); printf("%s\n", str); } clReleaseContext(context); } if (list_devices_only) return 0; context = clCreateContext(0, 1, &device_ids[opencl_device_id], NULL, NULL, &err); CHECK_CL_ERROR2(err, clCreateContext); program = clCreateProgramWithSource(context, 1, (const char **)&kernel_source, NULL, &err); CHECK_CL_ERROR2(err, clCreateProgramWithSource); CHECK_CL_ERROR(clBuildProgram(program, 0, NULL, build_options, NULL, NULL)); size_t binary_sizes; char *binary; CHECK_CL_ERROR(clGetProgramInfo(program, CL_PROGRAM_BINARY_SIZES, sizeof(size_t), &binary_sizes, NULL)); binary = malloc(sizeof(char)*binary_sizes); if (!binary) { printf("malloc(binary) failed\n"); exit(1); } CHECK_CL_ERROR(clGetProgramInfo(program, CL_PROGRAM_BINARIES, sizeof(unsigned char*), &binary, NULL)); CHECK_CL_ERROR(clReleaseProgram(program)); CHECK_CL_ERROR(clReleaseContext(context)); if (poclu_write_file(output_file, binary, binary_sizes)) ERRNO_EXIT(output_file); free(binary); return 0; }