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) return;
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 )) return;
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;
283 /* destroy a process when its refcount is 0 */
284 static void process_destroy( struct object *obj )
286 struct process *process = (struct process *)obj;
287 assert( obj->ops == &process_ops );
289 /* we can't have a thread remaining */
290 assert( !process->thread_list );
291 if (process->next) process->next->prev = process->prev;
292 if (process->prev) process->prev->next = process->next;
293 else first_process = process->next;
294 if (process->init_event) release_object( process->init_event );
295 if (process->idle_event) release_object( process->idle_event );
296 if (process->queue) release_object( process->queue );
297 if (process->atom_table) release_object( process->atom_table );
298 if (process->exe.file) release_object( process->exe.file );
301 /* dump a process on stdout for debugging purposes */
302 static void process_dump( struct object *obj, int verbose )
304 struct process *process = (struct process *)obj;
305 assert( obj->ops == &process_ops );
307 fprintf( stderr, "Process next=%p prev=%p console=%p/%p handles=%p\n",
308 process->next, process->prev, process->console_in, process->console_out,
312 static int process_signaled( struct object *obj, struct thread *thread )
314 struct process *process = (struct process *)obj;
315 return !process->running_threads;
319 static void process_poll_event( struct object *obj, int event )
321 struct process *process = (struct process *)obj;
322 assert( obj->ops == &process_ops );
324 if (event & (POLLERR | POLLHUP)) set_select_events( obj, -1 );
325 else if (event & POLLIN) receive_fd( process );
328 static void startup_info_destroy( struct object *obj )
330 struct startup_info *info = (struct startup_info *)obj;
331 assert( obj->ops == &startup_info_ops );
332 if (info->filename) free( info->filename );
333 if (info->exe_file) release_object( info->exe_file );
334 if (info->process) release_object( info->process );
335 if (info->thread) release_object( info->thread );
338 info->owner->info = NULL;
339 release_object( info->owner );
343 static void startup_info_dump( struct object *obj, int verbose )
345 struct startup_info *info = (struct startup_info *)obj;
346 assert( obj->ops == &startup_info_ops );
348 fprintf( stderr, "Startup info flags=%x in=%d out=%d err=%d name='%s'\n",
349 info->start_flags, info->hstdin, info->hstdout, info->hstderr, info->filename );
352 static int startup_info_signaled( struct object *obj, struct thread *thread )
354 struct startup_info *info = (struct startup_info *)obj;
355 return (info->thread != NULL);
359 /* get a process from an id (and increment the refcount) */
360 struct process *get_process_from_id( void *id )
362 struct process *p = first_process;
363 while (p && (p != id)) p = p->next;
364 if (p) grab_object( p );
365 else set_error( STATUS_INVALID_PARAMETER );
369 /* get a process from a handle (and increment the refcount) */
370 struct process *get_process_from_handle( handle_t handle, unsigned int access )
372 return (struct process *)get_handle_obj( current->process, handle,
373 access, &process_ops );
376 /* add a dll to a process list */
377 static struct process_dll *process_load_dll( struct process *process, struct file *file,
380 struct process_dll *dll;
382 /* make sure we don't already have one with the same base address */
383 for (dll = process->exe.next; dll; dll = dll->next) if (dll->base == base)
385 set_error( STATUS_INVALID_PARAMETER );
389 if ((dll = mem_alloc( sizeof(*dll) )))
391 dll->prev = &process->exe;
394 if (file) dll->file = (struct file *)grab_object( file );
395 if ((dll->next = process->exe.next)) dll->next->prev = dll;
396 process->exe.next = dll;
401 /* remove a dll from a process list */
402 static void process_unload_dll( struct process *process, void *base )
404 struct process_dll *dll;
406 for (dll = process->exe.next; dll; dll = dll->next)
408 if (dll->base == base)
410 if (dll->file) release_object( dll->file );
411 if (dll->next) dll->next->prev = dll->prev;
412 if (dll->prev) dll->prev->next = dll->next;
414 generate_debug_event( current, UNLOAD_DLL_DEBUG_EVENT, base );
418 set_error( STATUS_INVALID_PARAMETER );
421 /* a process has been killed (i.e. its last thread died) */
422 static void process_killed( struct process *process )
424 assert( !process->thread_list );
425 gettimeofday( &process->end_time, NULL );
426 if (process->handles) release_object( process->handles );
427 process->handles = NULL;
428 free_console( process );
429 while (process->exe.next)
431 struct process_dll *dll = process->exe.next;
432 process->exe.next = dll->next;
433 if (dll->file) release_object( dll->file );
436 if (process->exe.file) release_object( process->exe.file );
437 process->exe.file = NULL;
438 wake_up( &process->obj, 0 );
439 if (!--running_processes)
441 /* last process died, close global handles */
442 close_global_handles();
443 /* this will cause the select loop to terminate */
444 if (!persistent_server) close_master_socket();
448 /* add a thread to a process running threads list */
449 void add_process_thread( struct process *process, struct thread *thread )
451 thread->proc_next = process->thread_list;
452 thread->proc_prev = NULL;
453 if (thread->proc_next) thread->proc_next->proc_prev = thread;
454 process->thread_list = thread;
455 if (!process->running_threads++) running_processes++;
456 grab_object( thread );
459 /* remove a thread from a process running threads list */
460 void remove_process_thread( struct process *process, struct thread *thread )
462 assert( process->running_threads > 0 );
463 assert( process->thread_list );
465 if (thread->proc_next) thread->proc_next->proc_prev = thread->proc_prev;
466 if (thread->proc_prev) thread->proc_prev->proc_next = thread->proc_next;
467 else process->thread_list = thread->proc_next;
469 if (!--process->running_threads)
471 /* we have removed the last running thread, exit the process */
472 process->exit_code = thread->exit_code;
473 generate_debug_event( thread, EXIT_PROCESS_DEBUG_EVENT, process );
474 process_killed( process );
476 else generate_debug_event( thread, EXIT_THREAD_DEBUG_EVENT, thread );
477 release_object( thread );
480 /* suspend all the threads of a process */
481 void suspend_process( struct process *process )
483 if (!process->suspend++)
485 struct thread *thread = process->thread_list;
486 for (; thread; thread = thread->proc_next)
488 if (!thread->suspend) stop_thread( thread );
493 /* resume all the threads of a process */
494 void resume_process( struct process *process )
496 assert (process->suspend > 0);
497 if (!--process->suspend)
499 struct thread *thread = process->thread_list;
500 for (; thread; thread = thread->proc_next)
502 if (!thread->suspend) continue_thread( thread );
507 /* kill a process on the spot */
508 void kill_process( struct process *process, struct thread *skip, int exit_code )
510 struct thread *thread = process->thread_list;
513 struct thread *next = thread->proc_next;
514 thread->exit_code = exit_code;
515 if (thread != skip) kill_thread( thread, 1 );
520 /* kill all processes being debugged by a given thread */
521 void kill_debugged_processes( struct thread *debugger, int exit_code )
523 for (;;) /* restart from the beginning of the list every time */
525 struct process *process = first_process;
526 /* find the first process being debugged by 'debugger' and still running */
527 while (process && (process->debugger != debugger || !process->running_threads))
528 process = process->next;
529 if (!process) return;
530 process->debugger = NULL;
531 kill_process( process, NULL, exit_code );
535 /* get all information about a process */
536 static void get_process_info( struct process *process, struct get_process_info_request *req )
539 req->debugged = (process->debugger != 0);
540 req->exit_code = process->exit_code;
541 req->priority = process->priority;
542 req->process_affinity = process->affinity;
543 req->system_affinity = 1;
546 /* set all information about a process */
547 static void set_process_info( struct process *process,
548 struct set_process_info_request *req )
550 if (req->mask & SET_PROCESS_INFO_PRIORITY)
551 process->priority = req->priority;
552 if (req->mask & SET_PROCESS_INFO_AFFINITY)
554 if (req->affinity != 1) set_error( STATUS_INVALID_PARAMETER );
555 else process->affinity = req->affinity;
559 /* read data from a process memory space */
560 /* len is the total size (in ints), max is the size we can actually store in the output buffer */
561 /* we read the total size in all cases to check for permissions */
562 static void read_process_memory( struct process *process, const int *addr,
563 size_t len, size_t max, int *dest )
565 struct thread *thread = process->thread_list;
567 if ((unsigned int)addr % sizeof(int)) /* address must be aligned */
569 set_error( STATUS_INVALID_PARAMETER );
572 if (!thread) /* process is dead */
574 set_error( STATUS_ACCESS_DENIED );
577 if (suspend_for_ptrace( thread ))
579 while (len > 0 && max)
581 if (read_thread_int( thread, addr++, dest++ ) == -1) goto done;
585 /* check the rest for read permission */
588 int dummy, page = get_page_size() / sizeof(int);
593 if (read_thread_int( thread, addr - 1, &dummy ) == -1) goto done;
595 if (len && (read_thread_int( thread, addr + len - 1, &dummy ) == -1)) goto done;
598 resume_thread( thread );
602 /* write data to a process memory space */
603 /* len is the total size (in ints), max is the size we can actually read from the input buffer */
604 /* we check the total size for write permissions */
605 static void write_process_memory( struct process *process, int *addr, size_t len,
606 size_t max, unsigned int first_mask,
607 unsigned int last_mask, const int *src )
609 struct thread *thread = process->thread_list;
611 if (!len || ((unsigned int)addr % sizeof(int))) /* address must be aligned */
613 set_error( STATUS_INVALID_PARAMETER );
616 if (!thread) /* process is dead */
618 set_error( STATUS_ACCESS_DENIED );
621 if (suspend_for_ptrace( thread ))
623 /* first word is special */
626 if (write_thread_int( thread, addr++, *src++, first_mask ) == -1) goto done;
630 else last_mask &= first_mask;
632 while (len > 1 && max)
634 if (write_thread_int( thread, addr++, *src++, ~0 ) == -1) goto done;
641 /* last word is special too */
642 if (write_thread_int( thread, addr, *src, last_mask ) == -1) goto done;
646 /* check the rest for write permission */
647 int page = get_page_size() / sizeof(int);
652 if (write_thread_int( thread, addr - 1, 0, 0 ) == -1) goto done;
654 if (len && (write_thread_int( thread, addr + len - 1, 0, 0 ) == -1)) goto done;
657 resume_thread( thread );
661 /* take a snapshot of currently running processes */
662 struct process_snapshot *process_snap( int *count )
664 struct process_snapshot *snapshot, *ptr;
665 struct process *process;
666 if (!running_processes) return NULL;
667 if (!(snapshot = mem_alloc( sizeof(*snapshot) * running_processes )))
670 for (process = first_process; process; process = process->next)
672 if (!process->running_threads) continue;
673 ptr->process = process;
674 ptr->threads = process->running_threads;
675 ptr->count = process->obj.refcount;
676 ptr->priority = process->priority;
677 grab_object( process );
680 *count = running_processes;
684 /* take a snapshot of the modules of a process */
685 struct module_snapshot *module_snap( struct process *process, int *count )
687 struct module_snapshot *snapshot, *ptr;
688 struct process_dll *dll;
691 for (dll = &process->exe; dll; dll = dll->next) total++;
692 if (!(snapshot = mem_alloc( sizeof(*snapshot) * total ))) return NULL;
694 for (ptr = snapshot, dll = &process->exe; dll; dll = dll->next, ptr++)
696 ptr->base = dll->base;
703 /* create a new process */
704 DECL_HANDLER(new_process)
706 size_t len = get_req_data_size( req );
707 struct startup_info *info;
711 fatal_protocol_error( current, "new_process: another process is being created\n" );
715 /* build the startup info for a new process */
716 if (!(info = alloc_object( &startup_info_ops, -1 ))) return;
717 info->inherit_all = req->inherit_all;
718 info->create_flags = req->create_flags;
719 info->start_flags = req->start_flags;
720 info->hstdin = req->hstdin;
721 info->hstdout = req->hstdout;
722 info->hstderr = req->hstderr;
723 info->cmd_show = req->cmd_show;
724 info->exe_file = NULL;
725 info->filename = NULL;
726 info->owner = (struct thread *)grab_object( current );
727 info->process = NULL;
731 !(info->exe_file = get_file_obj( current->process, req->exe_file, GENERIC_READ )))
734 if (!(info->filename = mem_alloc( len + 1 ))) goto done;
736 memcpy( info->filename, get_req_data(req), len );
737 info->filename[len] = 0;
738 current->info = info;
739 req->info = alloc_handle( current->process, info, SYNCHRONIZE, FALSE );
742 release_object( info );
745 /* Retrieve information about a newly started process */
746 DECL_HANDLER(get_new_process_info)
748 struct startup_info *info;
752 if ((info = (struct startup_info *)get_handle_obj( current->process, req->info,
753 0, &startup_info_ops )))
755 req->pid = get_process_id( info->process );
756 req->tid = get_thread_id( info->thread );
757 req->phandle = alloc_handle( current->process, info->process,
758 PROCESS_ALL_ACCESS, req->pinherit );
759 req->thandle = alloc_handle( current->process, info->thread,
760 THREAD_ALL_ACCESS, req->tinherit );
761 if (info->process->init_event)
762 req->event = alloc_handle( current->process, info->process->init_event,
763 EVENT_ALL_ACCESS, 0 );
764 release_object( info );
775 /* initialize a new process */
776 DECL_HANDLER(init_process)
778 if (!current->unix_pid)
780 fatal_protocol_error( current, "init_process: init_thread not called yet\n" );
783 current->process->ldt_copy = req->ldt_copy;
784 init_process( req->ppid, req );
787 /* signal the end of the process initialization */
788 DECL_HANDLER(init_process_done)
790 struct file *file = NULL;
791 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 );
802 if (process->exe.file) release_object( process->exe.file );
803 process->exe.file = file;
805 generate_startup_debug_events( current->process, req->entry );
806 set_event( process->init_event );
807 release_object( process->init_event );
808 process->init_event = NULL;
809 if (req->gui) process->idle_event = create_event( NULL, 0, 1, 0 );
810 if (current->suspend + current->process->suspend > 0) stop_thread( current );
811 req->debugged = (current->process->debugger != 0);
814 /* open a handle to a process */
815 DECL_HANDLER(open_process)
817 struct process *process = get_process_from_id( req->pid );
821 req->handle = alloc_handle( current->process, process, req->access, req->inherit );
822 release_object( process );
826 /* terminate a process */
827 DECL_HANDLER(terminate_process)
829 struct process *process;
831 if ((process = get_process_from_handle( req->handle, PROCESS_TERMINATE )))
833 req->self = (current->process == process);
834 kill_process( process, current, req->exit_code );
835 release_object( process );
839 /* fetch information about a process */
840 DECL_HANDLER(get_process_info)
842 struct process *process;
844 if ((process = get_process_from_handle( req->handle, PROCESS_QUERY_INFORMATION )))
846 get_process_info( process, req );
847 release_object( process );
851 /* set information about a process */
852 DECL_HANDLER(set_process_info)
854 struct process *process;
856 if ((process = get_process_from_handle( req->handle, PROCESS_SET_INFORMATION )))
858 set_process_info( process, req );
859 release_object( process );
863 /* read data from a process address space */
864 DECL_HANDLER(read_process_memory)
866 struct process *process;
868 if ((process = get_process_from_handle( req->handle, PROCESS_VM_READ )))
870 size_t maxlen = get_req_data_size(req) / sizeof(int);
871 read_process_memory( process, req->addr, req->len, maxlen, get_req_data(req) );
872 release_object( process );
876 /* write data to a process address space */
877 DECL_HANDLER(write_process_memory)
879 struct process *process;
881 if ((process = get_process_from_handle( req->handle, PROCESS_VM_WRITE )))
883 size_t maxlen = get_req_data_size(req) / sizeof(int);
884 write_process_memory( process, req->addr, req->len, maxlen,
885 req->first_mask, req->last_mask, get_req_data(req) );
886 release_object( process );
890 /* notify the server that a dll has been loaded */
891 DECL_HANDLER(load_dll)
893 struct process_dll *dll;
894 struct file *file = NULL;
897 !(file = get_file_obj( current->process, req->handle, GENERIC_READ ))) return;
899 if ((dll = process_load_dll( current->process, file, req->base )))
901 dll->dbg_offset = req->dbg_offset;
902 dll->dbg_size = req->dbg_size;
903 dll->name = req->name;
904 /* only generate event if initialization is done */
905 if (!current->process->init_event)
906 generate_debug_event( current, LOAD_DLL_DEBUG_EVENT, dll );
908 if (file) release_object( file );
911 /* notify the server that a dll is being unloaded */
912 DECL_HANDLER(unload_dll)
914 process_unload_dll( current->process, req->base );
917 /* wait for a process to start waiting on input */
918 /* FIXME: only returns event for now, wait is done in the client */
919 DECL_HANDLER(wait_input_idle)
921 struct process *process;
924 if ((process = get_process_from_handle( req->handle, PROCESS_QUERY_INFORMATION )))
926 if (process->idle_event && process != current->process && process->queue != current->queue)
927 req->event = alloc_handle( current->process, process->idle_event,
928 EVENT_ALL_ACCESS, 0 );
929 release_object( process );