diff --git a/src/sbbs3/js_global.c b/src/sbbs3/js_global.c index 6dd6b103aa85b085337d6954218733b06be26adf..82740aa6b03891b2c4a97318b39edf2116f9deb9 100644 --- a/src/sbbs3/js_global.c +++ b/src/sbbs3/js_global.c @@ -2,7 +2,11 @@ /* Synchronet JavaScript "global" object properties/methods for all servers */ +<<<<<<< js_global.c /* $Id$ */ +======= +/* $Id$ */ +>>>>>>> 1.258 /**************************************************************************** * @format.tab-size 4 (Plain Text/Source Code File Header) * @@ -2792,6 +2796,31 @@ js_disksize(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) return(JS_TRUE); } +static JSBool +js_kill(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + int32 pid=0; + int32 sig=0; + int ds; + jsrefcount rc; + + if(JSVAL_IS_VOID(argv[0])) + return(JS_TRUE); + + if(argc<2) /* Require two arguments here - is this correct handling? */ + return(JS_FALSE); + + /* Convert JS values to C integers.. */ + JS_ValueToInt32(cx,argv[0],&sig); + JS_ValueToInt32(cx,argv[1],&pid); + + rc=JS_SUSPENDREQUEST(cx); + ds=kill(sig, pid); + JS_RESUMEREQUEST(cx, rc); + JS_NewNumberValue(cx,ds,rval); + + return(JS_TRUE); +} static JSBool js_socket_select(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) @@ -3301,6 +3330,12 @@ static jsSyncMethodSpec js_global_functions[] = { "specify a <i>unit_size</i> of <tt>1024</tt> to return the total disk size in <i>kilobytes</i>.") ,314 }, + {"kill", js_kill, 2, JSTYPE_NUMBER, +JSDOCSTR("processid, signal") + ,JSDOCSTR("send a signal to a process, returns a value that should be " + "parsed via signal.js. Useful for checking procees ID validity.") + ,311 + }, {"socket_select", js_socket_select, 0, JSTYPE_ARRAY, JSDOCSTR("[array of socket objects or descriptors] [,timeout=<tt>0</tt>] [,write=<tt>false</tt>]") ,JSDOCSTR("checks an array of socket objects or descriptors for read or write ability (default is <i>read</i>), " "default timeout value is 0.0 seconds (immediate timeout), "