Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
bb9f7a93
Commit
bb9f7a93
authored
May 09, 2004
by
joreland@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stop entire process group (if child has forked)
Impl. to handle "angle" process of ndb
parent
b8027810
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
15 deletions
+21
-15
ndb/src/cw/cpcd/Process.cpp
ndb/src/cw/cpcd/Process.cpp
+21
-15
No files found.
ndb/src/cw/cpcd/Process.cpp
View file @
bb9f7a93
...
@@ -27,6 +27,8 @@
...
@@ -27,6 +27,8 @@
#include <pwd.h>
#include <pwd.h>
#include <sys/stat.h>
#include <sys/stat.h>
#include <sys/resource.h>
#include <sys/resource.h>
#include <sys/types.h>
#include <sys/wait.h>
void
void
CPCD
::
Process
::
print
(
FILE
*
f
){
CPCD
::
Process
::
print
(
FILE
*
f
){
...
@@ -103,7 +105,7 @@ bool
...
@@ -103,7 +105,7 @@ bool
CPCD
::
Process
::
isRunning
()
{
CPCD
::
Process
::
isRunning
()
{
if
(
m_pid
<=
1
){
if
(
m_pid
<=
1
){
logger
.
critical
(
"isRunning(%d) invalid pid: %d"
,
m_id
,
m_pid
);
//
logger.critical("isRunning(%d) invalid pid: %d", m_id, m_pid);
return
false
;
return
false
;
}
}
/* Check if there actually exists a process with such a pid */
/* Check if there actually exists a process with such a pid */
...
@@ -355,7 +357,7 @@ CPCD::Process::start() {
...
@@ -355,7 +357,7 @@ CPCD::Process::start() {
*/
*/
switch
(
pid
=
fork
())
{
switch
(
pid
=
fork
())
{
case
0
:
/* Child */
case
0
:
/* Child */
setsid
();
writePid
(
getpid
());
writePid
(
getpid
());
if
(
runas
(
m_runas
.
c_str
())
==
0
){
if
(
runas
(
m_runas
.
c_str
())
==
0
){
do_exec
();
do_exec
();
...
@@ -384,11 +386,11 @@ CPCD::Process::start() {
...
@@ -384,11 +386,11 @@ CPCD::Process::start() {
pid_t
pid
;
pid_t
pid
;
switch
(
pid
=
fork
())
{
switch
(
pid
=
fork
())
{
case
0
:
/* Child */
case
0
:
/* Child */
setsid
();
writePid
(
getpid
());
writePid
(
getpid
());
if
(
runas
(
m_runas
.
c_str
())
!=
0
){
if
(
runas
(
m_runas
.
c_str
())
!=
0
){
_exit
(
1
);
_exit
(
1
);
}
}
setsid
();
do_exec
();
do_exec
();
_exit
(
1
);
_exit
(
1
);
/* NOTREACHED */
/* NOTREACHED */
...
@@ -423,11 +425,11 @@ CPCD::Process::start() {
...
@@ -423,11 +425,11 @@ CPCD::Process::start() {
while
(
readPid
()
<
0
){
while
(
readPid
()
<
0
){
sched_yield
();
sched_yield
();
}
}
if
(
pid
!=
-
1
&&
pid
!=
m_pid
){
if
(
pid
!=
-
1
&&
pid
!=
m_pid
){
logger
.
error
(
"pid and m_pid don't match: %d %d"
,
pid
,
m_pid
);
logger
.
error
(
"pid and m_pid don't match: %d %d"
,
pid
,
m_pid
);
}
}
if
(
isRunning
()){
if
(
isRunning
()){
m_status
=
RUNNING
;
m_status
=
RUNNING
;
return
0
;
return
0
;
...
@@ -449,28 +451,32 @@ CPCD::Process::stop() {
...
@@ -449,28 +451,32 @@ CPCD::Process::stop() {
}
}
m_status
=
STOPPING
;
m_status
=
STOPPING
;
int
ret
=
kill
((
pid_t
)
m_pid
,
SIGTERM
);
const
pid_t
pgid
=
-
getpgid
(
m_pid
);
int
ret
=
kill
(
pgid
,
SIGTERM
);
switch
(
ret
)
{
switch
(
ret
)
{
case
0
:
case
0
:
logger
.
debug
(
"Sent SIGTERM to pid %d"
,
(
int
)
m_p
id
);
logger
.
debug
(
"Sent SIGTERM to pid %d"
,
(
int
)
pg
id
);
break
;
break
;
default:
default:
logger
.
debug
(
"kill pid: %d : %s"
,
(
int
)
m_p
id
,
strerror
(
errno
));
logger
.
debug
(
"kill pid: %d : %s"
,
(
int
)
pg
id
,
strerror
(
errno
));
break
;
break
;
}
}
if
(
isRunning
()){
errno
=
0
;
ret
=
kill
((
pid_t
)
m_pid
,
SIGKILL
);
ret
=
kill
(
pgid
,
0
);
if
(
ret
==
0
)
{
errno
=
0
;
ret
=
kill
(
pgid
,
SIGKILL
);
switch
(
ret
)
{
switch
(
ret
)
{
case
0
:
case
0
:
logger
.
debug
(
"Sent SIGKILL to pid %d"
,
(
int
)
m_p
id
);
logger
.
debug
(
"Sent SIGKILL to pid %d"
,
(
int
)
pg
id
);
break
;
break
;
default:
default:
logger
.
debug
(
"kill pid: %d : %s
\n
"
,
(
int
)
m_p
id
,
strerror
(
errno
));
logger
.
debug
(
"kill pid: %d : %s
\n
"
,
(
int
)
pg
id
,
strerror
(
errno
));
break
;
break
;
}
}
}
}
m_pid
=
-
1
;
m_pid
=
-
1
;
m_status
=
STOPPED
;
m_status
=
STOPPED
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment