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
75bf02a2
Commit
75bf02a2
authored
14 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Created check_pid() and terminate_pid() wrapper functions.
parent
0b053ef3
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/xpdev/genwrap.c
+42
-0
42 additions, 0 deletions
src/xpdev/genwrap.c
src/xpdev/genwrap.h
+4
-0
4 additions, 0 deletions
src/xpdev/genwrap.h
with
46 additions
and
0 deletions
src/xpdev/genwrap.c
+
42
−
0
View file @
75bf02a2
...
...
@@ -560,3 +560,45 @@ long double DLLCALL xp_timer(void)
#endif
return
(
ret
);
}
/* Returns TRUE if specified process is running */
BOOL
DLLCALL
check_pid
(
pid_t
pid
)
{
#if defined(__unix__)
return
(
kill
(
pid
,
0
)
==
0
);
#elif defined(_WIN32)
HANDLE
h
;
BOOL
result
=
FALSE
;
if
((
h
=
OpenProcess
(
PROCESS_QUERY_INFORMATION
,
/* inheritable: */
FALSE
,
pid
))
!=
NULL
)
{
DWORD
code
;
if
(
GetExitCodeProcess
(
h
,
&
code
)
==
TRUE
&&
code
==
STILL_ACTIVE
)
result
=
TRUE
;
CloseHandle
(
h
);
}
return
result
;
#else
return
FALSE
;
/* Need check_pid() definition! */
#endif
}
/* Terminate (unconditionally) the specified process */
BOOL
DLLCALL
terminate_pid
(
pid_t
pid
)
{
#if defined(__unix__)
return
(
kill
(
pid
,
SIGKILL
)
==
0
);
#elif defined(_WIN32)
HANDLE
h
;
BOOL
result
=
FALSE
;
if
((
h
=
OpenProcess
(
PROCESS_TERMINATE
,
/* inheritable: */
FALSE
,
pid
))
!=
NULL
)
{
if
(
TerminateProcess
(
h
,
255
))
result
=
TRUE
;
CloseHandle
(
h
);
}
return
result
;
#else
return
FALSE
;
/* Need check_pid() definition! */
#endif
}
This diff is collapsed.
Click to expand it.
src/xpdev/genwrap.h
+
4
−
0
View file @
75bf02a2
...
...
@@ -60,6 +60,7 @@
#endif
#elif defined(_WIN32)
#include
<process.h>
/* getpid() */
typedef
DWORD
pid_t
;
#endif
#if !defined(_WIN32)
...
...
@@ -348,6 +349,9 @@ typedef clock_t msclock_t;
msclock_t
msclock
(
void
);
#endif
DLLEXPORT
BOOL
DLLCALL
check_pid
(
pid_t
);
DLLEXPORT
BOOL
DLLCALL
terminate_pid
(
pid_t
);
#if defined(__cplusplus)
}
#endif
...
...
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