Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
9109c3e6
Commit
9109c3e6
authored
14 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Revert Cyan's mod (removing global kill() function), created system.check_pid()
and system.terminate_pid() methods - untested.
parent
63082ff9
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/sbbs3/js_global.c
+0
-35
0 additions, 35 deletions
src/sbbs3/js_global.c
src/sbbs3/js_system.c
+51
-0
51 additions, 0 deletions
src/sbbs3/js_system.c
with
51 additions
and
35 deletions
src/sbbs3/js_global.c
+
0
−
35
View file @
9109c3e6
...
...
@@ -2792,34 +2792,6 @@ 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
);
if
(
ds
==
-
1
)
ds
=
errno
;
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
)
{
...
...
@@ -3328,13 +3300,6 @@ 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 system process, returns 0 on success, and "
"a non-zero errno value upon failure that is likely platform dependent."
" Useful for checking process ID validity (i.e., by sending signal 0.)"
)
,
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), "
...
...
This diff is collapsed.
Click to expand it.
src/sbbs3/js_system.c
+
51
−
0
View file @
9109c3e6
...
...
@@ -1473,6 +1473,47 @@ js_chkname(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
return
(
JS_TRUE
);
}
static
JSBool
js_chkpid
(
JSContext
*
cx
,
JSObject
*
obj
,
uintN
argc
,
jsval
*
argv
,
jsval
*
rval
)
{
int32
pid
=
0
;
jsrefcount
rc
;
*
rval
=
JSVAL_FALSE
;
if
(
argc
<
1
)
return
(
JS_TRUE
);
JS_ValueToInt32
(
cx
,
argv
[
0
],
&
pid
);
rc
=
JS_SUSPENDREQUEST
(
cx
);
*
rval
=
BOOLEAN_TO_JSVAL
(
check_pid
(
pid
));
JS_RESUMEREQUEST
(
cx
,
rc
);
return
(
JS_TRUE
);
}
static
JSBool
js_killpid
(
JSContext
*
cx
,
JSObject
*
obj
,
uintN
argc
,
jsval
*
argv
,
jsval
*
rval
)
{
int32
pid
=
0
;
jsrefcount
rc
;
*
rval
=
JSVAL_FALSE
;
if
(
argc
<
1
)
return
(
JS_TRUE
);
JS_ValueToInt32
(
cx
,
argv
[
0
],
&
pid
);
rc
=
JS_SUSPENDREQUEST
(
cx
);
*
rval
=
BOOLEAN_TO_JSVAL
(
terminate_pid
(
pid
));
JS_RESUMEREQUEST
(
cx
,
rc
);
return
(
JS_TRUE
);
}
static
jsSyncMethodSpec
js_system_functions
[]
=
{
{
"username"
,
js_username
,
1
,
JSTYPE_STRING
,
JSDOCSTR
(
"number"
)
,
JSDOCSTR
(
"returns name of user in specified user record <i>number</i>, or empty string if not found"
)
...
...
@@ -1571,6 +1612,16 @@ static jsSyncMethodSpec js_system_functions[] = {
"returns <i>true</i> if it is valid"
)
,
315
},
{
"check_pid"
,
js_chkpid
,
1
,
JSTYPE_BOOLEAN
,
JSDOCSTR
(
"process-ID"
)
,
JSDOCSTR
(
"checks that the provided process ID is a valid executing process on the system, "
"returns <i>true</i> if it is valid"
)
,
315
},
{
"terminate_pid"
,
js_killpid
,
1
,
JSTYPE_BOOLEAN
,
JSDOCSTR
(
"process-ID"
)
,
JSDOCSTR
(
"terminates executing process on the system with the specified process ID, "
"returns <i>true</i> on success"
)
,
315
},
{
0
}
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment