Author: dick
Date: 2005-04-11 07:09:07 -0400 (Mon, 11 Apr 2005)
New Revision: 42782
Modified:
branches/dick/io-layer-no-daemon/handles-private.h
branches/dick/io-layer-no-daemon/handles.c
branches/dick/io-layer-no-daemon/processes.c
Log:
Remove some dead code, and make process kill work again
Modified: branches/dick/io-layer-no-daemon/handles-private.h
===================================================================
--- branches/dick/io-layer-no-daemon/handles-private.h 2005-04-11 10:04:27 UTC
(rev 42781)
+++ branches/dick/io-layer-no-daemon/handles-private.h 2005-04-11 11:09:07 UTC
(rev 42782)
@@ -80,18 +80,6 @@
extern int _wapi_handle_wait_signal_handle (gpointer handle);
extern int _wapi_handle_timedwait_signal_handle (gpointer handle,
struct timespec *timeout);
-extern gboolean _wapi_handle_process_fork (guint32 cmd, guint32 env,
- guint32 dir, gboolean inherit,
- guint32 flags,
- gpointer stdin_handle,
- gpointer stdout_handle,
- gpointer stderr_handle,
- gpointer *process_handle,
- gpointer *thread_handle,
- guint32 *pid, guint32 *tid);
-
-extern gboolean _wapi_handle_process_kill (pid_t pid, guint32 signo,
- gint *err);
extern gboolean _wapi_handle_get_or_set_share (dev_t device, ino_t inode,
guint32 new_sharemode,
guint32 new_access,
Modified: branches/dick/io-layer-no-daemon/handles.c
===================================================================
--- branches/dick/io-layer-no-daemon/handles.c 2005-04-11 10:04:27 UTC (rev
42781)
+++ branches/dick/io-layer-no-daemon/handles.c 2005-04-11 11:09:07 UTC (rev
42782)
@@ -1456,128 +1456,6 @@
}
}
-gboolean _wapi_handle_process_fork (guint32 cmd, guint32 env, guint32 dir,
- gboolean inherit, guint32 flags,
- gpointer stdin_handle,
- gpointer stdout_handle,
- gpointer stderr_handle,
- gpointer *process_handle,
- gpointer *thread_handle, guint32 *pid,
- guint32 *tid)
-{
-#if 0
- WapiHandleRequest fork_proc={0};
- WapiHandleResponse fork_proc_resp={0};
- int in_fd, out_fd, err_fd;
-
- if(shared!=TRUE) {
- return(FALSE);
- }
-
- fork_proc.type=WapiHandleRequestType_ProcessFork;
- fork_proc.u.process_fork.cmd=cmd;
- fork_proc.u.process_fork.env=env;
- fork_proc.u.process_fork.dir=dir;
- fork_proc.u.process_fork.stdin_handle=GPOINTER_TO_UINT (stdin_handle);
- fork_proc.u.process_fork.stdout_handle=GPOINTER_TO_UINT (stdout_handle);
- fork_proc.u.process_fork.stderr_handle=GPOINTER_TO_UINT (stderr_handle);
- fork_proc.u.process_fork.inherit=inherit;
- fork_proc.u.process_fork.flags=flags;
-
- in_fd = GPOINTER_TO_UINT (stdin_handle);
- out_fd = GPOINTER_TO_UINT (stdout_handle);
- err_fd = GPOINTER_TO_UINT (stderr_handle);
-
- if(in_fd==-1 || out_fd==-1 || err_fd==-1) {
- /* We were given duff handles */
- /* FIXME: error code */
- return(FALSE);
- }
-
- _wapi_daemon_request_response_with_fds (daemon_sock, &fork_proc,
- &fork_proc_resp, in_fd,
- out_fd, err_fd);
- if(fork_proc_resp.type==WapiHandleResponseType_ProcessFork) {
- *process_handle=GUINT_TO_POINTER
(fork_proc_resp.u.process_fork.process_handle);
- *thread_handle=GUINT_TO_POINTER
(fork_proc_resp.u.process_fork.thread_handle);
- *pid=fork_proc_resp.u.process_fork.pid;
- *tid=fork_proc_resp.u.process_fork.tid;
-
- /* If there was an internal error, the handles will be
- * 0. If there was an error forking or execing, the
- * handles will have values, and process_handle's
- * exec_errno will be set, and the handle will be
- * signalled immediately.
- */
- if(*process_handle==0 || *thread_handle==0) {
- return(FALSE);
- } else {
- /* This call returns new handles, so we need to do
- * a little bookkeeping
- */
- if (_wapi_private_data != NULL) {
- guint32 segment, idx;
-
- _wapi_handle_segment (*process_handle,
- &segment, &idx);
- _wapi_handle_ensure_mapped (segment);
- _wapi_handle_get_private_segment
(segment)->handles[idx].type = WAPI_HANDLE_PROCESS;
-
- _wapi_handle_segment (*thread_handle,
- &segment, &idx);
- _wapi_handle_ensure_mapped (segment);
- _wapi_handle_get_private_segment
(segment)->handles[idx].type = WAPI_HANDLE_THREAD;
- }
-
- return(TRUE);
- }
- } else {
- g_warning ("%s: bogus daemon response, type %d", __func__,
- fork_proc_resp.type);
- g_assert_not_reached ();
- }
-
- return(FALSE);
-#else
- return(FALSE);
-#endif
-}
-
-gboolean
-_wapi_handle_process_kill (pid_t process, guint32 signo, gint *errnum)
-{
-#if 0
- WapiHandleRequest killproc = {0};
- WapiHandleResponse killprocresp = {0};
- gint result;
-
- if (shared != TRUE) {
- if (errnum) *errnum = EINVAL;
- return FALSE;
- }
-
- killproc.type = WapiHandleRequestType_ProcessKill;
- killproc.u.process_kill.pid = process;
- killproc.u.process_kill.signo = signo;
-
- _wapi_daemon_request_response (daemon_sock, &killproc, &killprocresp);
-
- if (killprocresp.type != WapiHandleResponseType_ProcessKill) {
- g_warning ("%s: bogus daemon response, type %d", __func__,
- killprocresp.type);
- g_assert_not_reached ();
- }
-
- result = killprocresp.u.process_kill.err;
- if (result != 0 && errnum != NULL)
- *errnum = (result == FALSE) ? result : 0;
-
- return (result == 0);
-#else
- return(FALSE);
-#endif
-}
-
gboolean _wapi_handle_get_or_set_share (dev_t device, ino_t inode,
guint32 new_sharemode,
guint32 new_access,
Modified: branches/dick/io-layer-no-daemon/processes.c
===================================================================
--- branches/dick/io-layer-no-daemon/processes.c 2005-04-11 10:04:27 UTC
(rev 42781)
+++ branches/dick/io-layer-no-daemon/processes.c 2005-04-11 11:09:07 UTC
(rev 42782)
@@ -1088,8 +1088,8 @@
{
struct _WapiHandle_process *process_handle;
gboolean ok;
- gint signo;
- gint err;
+ int signo;
+ int ret;
ok = _wapi_lookup_handle (process, WAPI_HANDLE_PROCESS,
(gpointer *) &process_handle);
@@ -1103,6 +1103,23 @@
}
signo = (exitCode == -1) ? SIGKILL : SIGTERM;
- return _wapi_handle_process_kill (process_handle->id, signo, &err);
+ ret = kill (process_handle->id, signo);
+ if (ret == -1) {
+ switch (errno) {
+ case EINVAL:
+ SetLastError (ERROR_INVALID_PARAMETER);
+ break;
+ case EPERM:
+ SetLastError (ERROR_ACCESS_DENIED);
+ break;
+ case ESRCH:
+ SetLastError (ERROR_PROC_NOT_FOUND);
+ break;
+ default:
+ SetLastError (ERROR_GEN_FAILURE);
+ }
+ }
+
+ return (ret == 0);
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches