2 * Server-side process management
4 * Copyright (C) 1998 Alexandre Julliard
17 #ifdef HAVE_SYS_SOCKET_H
18 # include <sys/socket.h>
30 /* process structure */
32 static struct process *first_process;
33 static int running_processes;
35 /* process operations */
37 static void process_dump( struct object *obj, int verbose );
38 static int process_signaled( struct object *obj, struct thread *thread );
39 static void process_poll_event( struct object *obj, int event );
40 static void process_destroy( struct object *obj );
42 static const struct object_ops process_ops =
44 sizeof(struct process), /* size */
45 process_dump, /* dump */
46 add_queue, /* add_queue */
47 remove_queue, /* remove_queue */
48 process_signaled, /* signaled */
49 no_satisfied, /* satisfied */
50 NULL, /* get_poll_events */
51 process_poll_event, /* poll_event */
52 no_get_fd, /* get_fd */
54 no_get_file_info, /* get_file_info */
55 process_destroy /* destroy */
58 /* process startup info */
62 struct object obj; /* object header */
63 int inherit_all; /* inherit all handles from parent */
64 int create_flags; /* creation flags */
65 int start_flags; /* flags from startup info */
66 handle_t hstdin; /* handle for stdin */
67 handle_t hstdout; /* handle for stdout */
68 handle_t hstderr; /* handle for stderr */
69 int cmd_show; /* main window show mode */
70 struct file *exe_file; /* file handle for main exe */
71 char *filename; /* file name for main exe */
72 struct thread *owner; /* owner thread (the one that created the new process) */
73 struct process *process; /* created process */
74 struct thread *thread; /* created thread */
77 static void startup_info_dump( struct object *obj, int verbose );
78 static int startup_info_signaled( struct object *obj, struct thread *thread );
79 static void startup_info_destroy( struct object *obj );
81 static const struct object_ops startup_info_ops =
83 sizeof(struct startup_info), /* size */
84 startup_info_dump, /* dump */
85 add_queue, /* add_queue */
86 remove_queue, /* remove_queue */
87 startup_info_signaled, /* signaled */
88 no_satisfied, /* satisfied */
89 NULL, /* get_poll_events */
90 NULL, /* poll_event */
91 no_get_fd, /* get_fd */
93 no_get_file_info, /* get_file_info */
94 startup_info_destroy /* destroy */
98 /* set the console and stdio handles for a newly created process */
99 static int set_process_console( struct process *process, struct process *parent,
100 struct startup_info *info, struct init_process_request *req )
102 if (process->create_flags & CREATE_NEW_CONSOLE)
104 if (!alloc_console( process )) return 0;
106 else if (parent && !(process->create_flags & DETACHED_PROCESS))
108 if (parent->console_in) process->console_in = grab_object( parent->console_in );
109 if (parent->console_out) process->console_out = grab_object( parent->console_out );
113 if (!info->inherit_all && !(info->start_flags & STARTF_USESTDHANDLES))
115 /* duplicate the handle from the parent into this process */
116 req->hstdin = duplicate_handle( parent, info->hstdin, process,
117 0, TRUE, DUPLICATE_SAME_ACCESS );
118 req->hstdout = duplicate_handle( parent, info->hstdout, process,
119 0, TRUE, DUPLICATE_SAME_ACCESS );
120 req->hstderr = duplicate_handle( parent, info->hstderr, process,
121 0, TRUE, DUPLICATE_SAME_ACCESS );
125 req->hstdin = info->hstdin;
126 req->hstdout = info->hstdout;
127 req->hstderr = info->hstderr;
132 /* no parent, use handles to the console for stdio */
133 req->hstdin = alloc_handle( process, process->console_in,
134 GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE, 1 );
135 req->hstdout = alloc_handle( process, process->console_out,
136 GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE, 1 );
137 req->hstderr = alloc_handle( process, process->console_out,
138 GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE, 1 );
140 /* some handles above may have been invalid; this is not an error */
141 if (get_error() == STATUS_INVALID_HANDLE) clear_error();
145 /* create a new process and its main thread */
146 struct thread *create_process( int fd )
148 struct process *process;
149 struct thread *thread = NULL;
152 if (!(process = alloc_object( &process_ops, fd ))) return NULL;
153 process->next = NULL;
154 process->prev = NULL;
155 process->thread_list = NULL;
156 process->debugger = NULL;
157 process->handles = NULL;
158 process->exit_code = STILL_ACTIVE;
159 process->running_threads = 0;
160 process->priority = NORMAL_PRIORITY_CLASS;
161 process->affinity = 1;
162 process->suspend = 0;
163 process->create_flags = 0;
164 process->console_in = NULL;
165 process->console_out = NULL;
166 process->init_event = NULL;
167 process->idle_event = NULL;
168 process->queue = NULL;
169 process->atom_table = NULL;
170 process->ldt_copy = NULL;
171 process->exe.next = NULL;
172 process->exe.prev = NULL;
173 process->exe.file = NULL;
174 process->exe.dbg_offset = 0;
175 process->exe.dbg_size = 0;
176 gettimeofday( &process->start_time, NULL );
177 if ((process->next = first_process) != NULL) process->next->prev = process;
178 first_process = process;
180 /* create the init done event */
181 if (!(process->init_event = create_event( NULL, 0, 1, 0 ))) goto error;
183 /* create the main thread */
184 if (pipe( request_pipe ) == -1)
189 send_client_fd( process, request_pipe[1], 0 );
190 close( request_pipe[1] );
191 if (!(thread = create_thread( request_pipe[0], process ))) goto error;
193 set_select_events( &process->obj, POLLIN ); /* start listening to events */
194 release_object( process );
198 if (thread) release_object( thread );
199 release_object( process );
203 /* initialize the current process and fill in the request */
204 static void init_process( int ppid, struct init_process_request *req )
206 struct process *process = current->process;
207 struct thread *parent_thread = get_thread_from_pid( ppid );
208 struct process *parent = NULL;
209 struct startup_info *info = NULL;
213 parent = parent_thread->process;
214 info = parent_thread->info;
217 fatal_protocol_error( current, "init_process: parent but no info\n" );
222 fatal_protocol_error( current, "init_process: called twice?\n" );
227 /* set the process flags */
228 process->create_flags = info ? info->create_flags : CREATE_NEW_CONSOLE;
230 /* create the handle table */
231 if (parent && info->inherit_all)
232 process->handles = copy_handle_table( process, parent );
234 process->handles = alloc_handle_table( process, 0 );
235 if (!process->handles) goto error;
237 /* retrieve the main exe file */
239 if (parent && info->exe_file)
241 process->exe.file = (struct file *)grab_object( info->exe_file );
242 if (!(req->exe_file = alloc_handle( process, process->exe.file, GENERIC_READ, 0 )))
246 /* set the process console */
247 if (!set_process_console( process, parent, info, req )) goto error;
251 /* attach to the debugger if requested */
252 if (process->create_flags & (DEBUG_PROCESS | DEBUG_ONLY_THIS_PROCESS))
253 set_process_debugger( process, parent_thread );
254 else if (parent && parent->debugger && !(parent->create_flags & DEBUG_ONLY_THIS_PROCESS))
255 set_process_debugger( process, parent->debugger );
258 /* thread will be actually suspended in init_done */
259 if (process->create_flags & CREATE_SUSPENDED) current->suspend++;
263 size_t size = strlen(info->filename);
264 if (size > get_req_data_size(req)) size = get_req_data_size(req);
265 req->start_flags = info->start_flags;
266 req->cmd_show = info->cmd_show;
267 memcpy( get_req_data(req), info->filename, size );
268 set_req_data_size( req, size );
269 info->process = (struct process *)grab_object( process );
270 info->thread = (struct thread *)grab_object( current );
271 wake_up( &info->obj, 0 );
275 req->start_flags = STARTF_USESTDHANDLES;
277 set_req_data_size( req, 0 );
279 req->create_flags = process->create_flags;
280 req->server_start = server_start_ticks;
284 /* destroy a process when its refcount is 0 */
285 static void process_destroy( struct object *obj )
287 struct process *process = (struct process *)obj;
288 assert( obj->ops == &process_ops );
290 /* we can't have a thread remaining */
291 assert( !process->thread_list );
292 if (process->next) process->next->prev = process->prev;
293 if (process->prev) process->prev->next = process->next;
294 else first_process = process->next;
295 if (process->init_event) release_object( process->init_event );
296 if (process->idle_event) release_object( process->idle_event );
297 if (process->queue) release_object( process->queue );
298 if (process->atom_table) release_object( process->atom_table );
299 if (process->exe.file) release_object( process->exe.file );
302 /* dump a process on stdout for debugging purposes */
303 static void process_dump( struct object *obj, int verbose )
305 struct process *process = (struct process *)obj;
306 assert( obj->ops == &process_ops );
308 fprintf( stderr, "Process next=%p prev=%p console=%p/%p handles=%p\n",
309 process->next, process->prev, process->console_in, process->console_out,
313 static int process_signaled( struct object *obj, struct thread *thread )
315 struct process *process = (struct process *)obj;
316 return !process->running_threads;
320 static void process_poll_event( struct object *obj, int event )
322 struct process *process = (struct process *)obj;
323 assert( obj->ops == &process_ops );
325 if (event & (POLLERR | POLLHUP)) set_select_events( obj, -1 );
326 else if (event & POLLIN) receive_fd( process );
329 static void startup_info_destroy( struct object *obj )
331 struct startup_info *info = (struct startup_info *)obj;
332 assert( obj->ops == &startup_info_ops );
333 if (info->filename) free( info->filename );
334 if (info->exe_file) release_object( info->exe_file );
335 if (info->process) release_object( info->process );
336 if (info->thread) release_object( info->thread );
339 info->owner->info = NULL;
340 release_object( info->owner );
344 static void startup_info_dump( struct object *obj, int verbose )
346 struct startup_info *info = (struct startup_info *)obj;
347 assert( obj->ops == &startup_info_ops );
349 fprintf( stderr, "Startup info flags=%x in=%d out=%d err=%d name='%s'\n",
350 info->start_flags, info->hstdin, info->hstdout, info->hstderr, info->filename );
353 static int startup_info_signaled( struct object *obj, struct thread *thread )
355 struct startup_info *info = (struct startup_info *)obj;
356 return (info->thread != NULL);
360 /* get a process from an id (and increment the refcount) */
361 struct process *get_process_from_id( void *id )
363 struct process *p = first_process;
364 while (p && (p != id)) p = p->next;
365 if (p) grab_object( p );
366 else set_error( STATUS_INVALID_PARAMETER );
370 /* get a process from a handle (and increment the refcount) */
371 struct process *get_process_from_handle( handle_t handle, unsigned int access )
373 return (struct process *)get_handle_obj( current->process, handle,
374 access, &process_ops );
377 /* add a dll to a process list */
378 static struct process_dll *process_load_dll( struct process *process, struct file *file,
381 struct process_dll *dll;
383 /* make sure we don't already have one with the same base address */
384 for (dll = process->exe.next; dll; dll = dll->next) if (dll->base == base)
386 set_error( STATUS_INVALID_PARAMETER );
390 if ((dll = mem_alloc( sizeof(*dll) )))
392 dll->prev = &process->exe;
395 if (file) dll->file = (struct file *)grab_object( file );
396 if ((dll->next = process->exe.next)) dll->next->prev = dll;
397 process->exe.next = dll;
402 /* remove a dll from a process list */
403 static void process_unload_dll( struct process *process, void *base )
405 struct process_dll *dll;
407 for (dll = process->exe.next; dll; dll = dll->next)
409 if (dll->base == base)
411 if (dll->file) release_object( dll->file );
412 if (dll->next) dll->next->prev = dll->prev;
413 if (dll->prev) dll->prev->next = dll->next;
415 generate_debug_event( current, UNLOAD_DLL_DEBUG_EVENT, base );
419 set_error( STATUS_INVALID_PARAMETER );
422 /* a process has been killed (i.e. its last thread died) */
423 static void process_killed( struct process *process )
425 assert( !process->thread_list );
426 gettimeofday( &process->end_time, NULL );
427 if (process->handles) release_object( process->handles );
428 process->handles = NULL;
429 free_console( process );
430 while (process->exe.next)
432 struct process_dll *dll = process->exe.next;
433 process->exe.next = dll->next;
434 if (dll->file) release_object( dll->file );
437 if (process->exe.file) release_object( process->exe.file );
438 process->exe.file = NULL;
439 wake_up( &process->obj, 0 );
440 if (!--running_processes)
442 /* last process died, close global handles */
443 close_global_handles();
444 /* this will cause the select loop to terminate */
445 if (!persistent_server) close_master_socket();
449 /* add a thread to a process running threads list */
450 void add_process_thread( struct process *process, struct thread *thread )
452 thread->proc_next = process->thread_list;
453 thread->proc_prev = NULL;
454 if (thread->proc_next) thread->proc_next->proc_prev = thread;
455 process->thread_list = thread;
456 if (!process->running_threads++) running_processes++;
457 grab_object( thread );
460 /* remove a thread from a process running threads list */
461 void remove_process_thread( struct process *process, struct thread *thread )
463 assert( process->running_threads > 0 );
464 assert( process->thread_list );
466 if (thread->proc_next) thread->proc_next->proc_prev = thread->proc_prev;
467 if (thread->proc_prev) thread->proc_prev->proc_next = thread->proc_next;
468 else process->thread_list = thread->proc_next;
470 if (!--process->running_threads)
472 /* we have removed the last running thread, exit the process */
473 process->exit_code = thread->exit_code;
474 generate_debug_event( thread, EXIT_PROCESS_DEBUG_EVENT, process );
475 process_killed( process );
477 else generate_debug_event( thread, EXIT_THREAD_DEBUG_EVENT, thread );
478 release_object( thread );
481 /* suspend all the threads of a process */
482 void suspend_process( struct process *process )
484 if (!process->suspend++)
486 struct thread *thread = process->thread_list;
487 for (; thread; thread = thread->proc_next)
489 if (!thread->suspend) stop_thread( thread );
494 /* resume all the threads of a process */
495 void resume_process( struct process *process )
497 assert (process->suspend > 0);
498 if (!--process->suspend)
500 struct thread *thread = process->thread_list;
501 for (; thread; thread = thread->proc_next)
503 if (!thread->suspend) continue_thread( thread );
508 /* kill a process on the spot */
509 void kill_process( struct process *process, struct thread *skip, int exit_code )
511 struct thread *thread = process->thread_list;
514 struct thread *next = thread->proc_next;
515 thread->exit_code = exit_code;
516 if (thread != skip) kill_thread( thread, 1 );
521 /* kill all processes being debugged by a given thread */
522 void kill_debugged_processes( struct thread *debugger, int exit_code )
524 for (;;) /* restart from the beginning of the list every time */
526 struct process *process = first_process;
527 /* find the first process being debugged by 'debugger' and still running */
528 while (process && (process->debugger != debugger || !process->running_threads))
529 process = process->next;
530 if (!process) return;
531 process->debugger = NULL;
532 kill_process( process, NULL, exit_code );
536 /* get all information about a process */
537 static void get_process_info( struct process *process, struct get_process_info_request *req )
540 req->debugged = (process->debugger != 0);
541 req->exit_code = process->exit_code;
542 req->priority = process->priority;
543 req->process_affinity = process->affinity;
544 req->system_affinity = 1;
547 /* set all information about a process */
548 static void set_process_info( struct process *process,
549 struct set_process_info_request *req )
551 if (req->mask & SET_PROCESS_INFO_PRIORITY)
552 process->priority = req->priority;
553 if (req->mask & SET_PROCESS_INFO_AFFINITY)
555 if (req->affinity != 1) set_error( STATUS_INVALID_PARAMETER );
556 else process->affinity = req->affinity;
560 /* read data from a process memory space */
561 /* len is the total size (in ints), max is the size we can actually store in the output buffer */
562 /* we read the total size in all cases to check for permissions */
563 static void read_process_memory( struct process *process, const int *addr,
564 size_t len, size_t max, int *dest )
566 struct thread *thread = process->thread_list;
568 if ((unsigned int)addr % sizeof(int)) /* address must be aligned */
570 set_error( STATUS_INVALID_PARAMETER );
573 if (!thread) /* process is dead */
575 set_error( STATUS_ACCESS_DENIED );
578 if (suspend_for_ptrace( thread ))
580 while (len > 0 && max)
582 if (read_thread_int( thread, addr++, dest++ ) == -1) goto done;
586 /* check the rest for read permission */
589 int dummy, page = get_page_size() / sizeof(int);
594 if (read_thread_int( thread, addr - 1, &dummy ) == -1) goto done;
596 if (len && (read_thread_int( thread, addr + len - 1, &dummy ) == -1)) goto done;
599 resume_thread( thread );
603 /* write data to a process memory space */
604 /* len is the total size (in ints), max is the size we can actually read from the input buffer */
605 /* we check the total size for write permissions */
606 static void write_process_memory( struct process *process, int *addr, size_t len,
607 size_t max, unsigned int first_mask,
608 unsigned int last_mask, const int *src )
610 struct thread *thread = process->thread_list;
612 if (!len || ((unsigned int)addr % sizeof(int))) /* address must be aligned */
614 set_error( STATUS_INVALID_PARAMETER );
617 if (!thread) /* process is dead */
619 set_error( STATUS_ACCESS_DENIED );
622 if (suspend_for_ptrace( thread ))
624 /* first word is special */
627 if (write_thread_int( thread, addr++, *src++, first_mask ) == -1) goto done;
631 else last_mask &= first_mask;
633 while (len > 1 && max)
635 if (write_thread_int( thread, addr++, *src++, ~0 ) == -1) goto done;
642 /* last word is special too */
643 if (write_thread_int( thread, addr, *src, last_mask ) == -1) goto done;
647 /* check the rest for write permission */
648 int page = get_page_size() / sizeof(int);
653 if (write_thread_int( thread, addr - 1, 0, 0 ) == -1) goto done;
655 if (len && (write_thread_int( thread, addr + len - 1, 0, 0 ) == -1)) goto done;
658 resume_thread( thread );
662 /* take a snapshot of currently running processes */
663 struct process_snapshot *process_snap( int *count )
665 struct process_snapshot *snapshot, *ptr;
666 struct process *process;
667 if (!running_processes) return NULL;
668 if (!(snapshot = mem_alloc( sizeof(*snapshot) * running_processes )))
671 for (process = first_process; process; process = process->next)
673 if (!process->running_threads) continue;
674 ptr->process = process;
675 ptr->threads = process->running_threads;
676 ptr->count = process->obj.refcount;
677 ptr->priority = process->priority;
678 grab_object( process );
681 *count = running_processes;
685 /* take a snapshot of the modules of a process */
686 struct module_snapshot *module_snap( struct process *process, int *count )
688 struct module_snapshot *snapshot, *ptr;
689 struct process_dll *dll;
692 for (dll = &process->exe; dll; dll = dll->next) total++;
693 if (!(snapshot = mem_alloc( sizeof(*snapshot) * total ))) return NULL;
695 for (ptr = snapshot, dll = &process->exe; dll; dll = dll->next, ptr++)
697 ptr->base = dll->base;
704 /* create a new process */
705 DECL_HANDLER(new_process)
707 size_t len = get_req_data_size( req );
708 struct startup_info *info;
712 fatal_protocol_error( current, "new_process: another process is being created\n" );
716 /* build the startup info for a new process */
717 if (!(info = alloc_object( &startup_info_ops, -1 ))) return;
718 info->inherit_all = req->inherit_all;
719 info->create_flags = req->create_flags;
720 info->start_flags = req->start_flags;
721 info->hstdin = req->hstdin;
722 info->hstdout = req->hstdout;
723 info->hstderr = req->hstderr;
724 info->cmd_show = req->cmd_show;
725 info->exe_file = NULL;
726 info->filename = NULL;
727 info->owner = (struct thread *)grab_object( current );
728 info->process = NULL;
732 !(info->exe_file = get_file_obj( current->process, req->exe_file, GENERIC_READ )))
735 if (!(info->filename = mem_alloc( len + 1 ))) goto done;
737 memcpy( info->filename, get_req_data(req), len );
738 info->filename[len] = 0;
739 current->info = info;
740 req->info = alloc_handle( current->process, info, SYNCHRONIZE, FALSE );
743 release_object( info );
746 /* Retrieve information about a newly started process */
747 DECL_HANDLER(get_new_process_info)
749 struct startup_info *info;
753 if ((info = (struct startup_info *)get_handle_obj( current->process, req->info,
754 0, &startup_info_ops )))
756 req->pid = get_process_id( info->process );
757 req->tid = get_thread_id( info->thread );
758 req->phandle = alloc_handle( current->process, info->process,
759 PROCESS_ALL_ACCESS, req->pinherit );
760 req->thandle = alloc_handle( current->process, info->thread,
761 THREAD_ALL_ACCESS, req->tinherit );
762 if (info->process->init_event)
763 req->event = alloc_handle( current->process, info->process->init_event,
764 EVENT_ALL_ACCESS, 0 );
765 release_object( info );
776 /* initialize a new process */
777 DECL_HANDLER(init_process)
779 if (!current->unix_pid)
781 fatal_protocol_error( current, "init_process: init_thread not called yet\n" );
784 current->process->ldt_copy = req->ldt_copy;
785 init_process( req->ppid, req );
788 /* signal the end of the process initialization */
789 DECL_HANDLER(init_process_done)
792 struct process *process = current->process;
793 if (!process->init_event)
795 fatal_protocol_error( current, "init_process_done: no event\n" );
798 process->exe.base = req->module;
799 process->exe.name = req->name;
801 if (req->exe_file && (file = get_file_obj( current->process, req->exe_file, GENERIC_READ )))
803 if (process->exe.file) release_object( process->exe.file );
804 process->exe.file = file;
806 generate_startup_debug_events( current->process, req->entry );
807 set_event( process->init_event );
808 release_object( process->init_event );
809 process->init_event = NULL;
810 if (req->gui) process->idle_event = create_event( NULL, 0, 1, 0 );
811 if (current->suspend + current->process->suspend > 0) stop_thread( current );
812 req->debugged = (current->process->debugger != 0);
815 /* open a handle to a process */
816 DECL_HANDLER(open_process)
818 struct process *process = get_process_from_id( req->pid );
822 req->handle = alloc_handle( current->process, process, req->access, req->inherit );
823 release_object( process );
827 /* terminate a process */
828 DECL_HANDLER(terminate_process)
830 struct process *process;
832 if ((process = get_process_from_handle( req->handle, PROCESS_TERMINATE )))
834 req->self = (current->process == process);
835 kill_process( process, current, req->exit_code );
836 release_object( process );
840 /* fetch information about a process */
841 DECL_HANDLER(get_process_info)
843 struct process *process;
845 if ((process = get_process_from_handle( req->handle, PROCESS_QUERY_INFORMATION )))
847 get_process_info( process, req );
848 release_object( process );
852 /* set information about a process */
853 DECL_HANDLER(set_process_info)
855 struct process *process;
857 if ((process = get_process_from_handle( req->handle, PROCESS_SET_INFORMATION )))
859 set_process_info( process, req );
860 release_object( process );
864 /* read data from a process address space */
865 DECL_HANDLER(read_process_memory)
867 struct process *process;
869 if ((process = get_process_from_handle( req->handle, PROCESS_VM_READ )))
871 size_t maxlen = get_req_data_size(req) / sizeof(int);
872 read_process_memory( process, req->addr, req->len, maxlen, get_req_data(req) );
873 release_object( process );
877 /* write data to a process address space */
878 DECL_HANDLER(write_process_memory)
880 struct process *process;
882 if ((process = get_process_from_handle( req->handle, PROCESS_VM_WRITE )))
884 size_t maxlen = get_req_data_size(req) / sizeof(int);
885 write_process_memory( process, req->addr, req->len, maxlen,
886 req->first_mask, req->last_mask, get_req_data(req) );
887 release_object( process );
891 /* notify the server that a dll has been loaded */
892 DECL_HANDLER(load_dll)
894 struct process_dll *dll;
895 struct file *file = NULL;
898 !(file = get_file_obj( current->process, req->handle, GENERIC_READ ))) return;
900 if ((dll = process_load_dll( current->process, file, req->base )))
902 dll->dbg_offset = req->dbg_offset;
903 dll->dbg_size = req->dbg_size;
904 dll->name = req->name;
905 /* only generate event if initialization is done */
906 if (!current->process->init_event)
907 generate_debug_event( current, LOAD_DLL_DEBUG_EVENT, dll );
909 if (file) release_object( file );
912 /* notify the server that a dll is being unloaded */
913 DECL_HANDLER(unload_dll)
915 process_unload_dll( current->process, req->base );
918 /* wait for a process to start waiting on input */
919 /* FIXME: only returns event for now, wait is done in the client */
920 DECL_HANDLER(wait_input_idle)
922 struct process *process;
925 if ((process = get_process_from_handle( req->handle, PROCESS_QUERY_INFORMATION )))
927 if (process->idle_event && process != current->process && process->queue != current->queue)
928 req->event = alloc_handle( current->process, process->idle_event,
929 EVENT_ALL_ACCESS, 0 );
930 release_object( process );