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
b886afc0
Commit
b886afc0
authored
May 11, 2004
by
joreland@mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cpcd - setsid - angle fixes
parent
d96ada53
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
25 deletions
+30
-25
ndb/src/cw/cpcd/Process.cpp
ndb/src/cw/cpcd/Process.cpp
+20
-21
ndb/src/mgmclient/test_cpcd/test_cpcd.cpp
ndb/src/mgmclient/test_cpcd/test_cpcd.cpp
+10
-4
No files found.
ndb/src/cw/cpcd/Process.cpp
View file @
b886afc0
...
@@ -110,7 +110,7 @@ CPCD::Process::isRunning() {
...
@@ -110,7 +110,7 @@ CPCD::Process::isRunning() {
}
}
/* Check if there actually exists a process with such a pid */
/* Check if there actually exists a process with such a pid */
errno
=
0
;
errno
=
0
;
int
s
=
kill
((
pid_t
)
m_pid
,
0
);
/* Sending "signal" 0 to a process only
int
s
=
kill
((
pid_t
)
-
m_pid
,
0
);
/* Sending "signal" 0 to a process only
* checkes if the process actually exists */
* checkes if the process actually exists */
if
(
s
!=
0
)
{
if
(
s
!=
0
)
{
switch
(
errno
)
{
switch
(
errno
)
{
...
@@ -127,7 +127,6 @@ CPCD::Process::isRunning() {
...
@@ -127,7 +127,6 @@ CPCD::Process::isRunning() {
}
}
return
false
;
return
false
;
}
}
return
true
;
return
true
;
}
}
...
@@ -149,7 +148,6 @@ CPCD::Process::readPid() {
...
@@ -149,7 +148,6 @@ CPCD::Process::readPid() {
f
=
fopen
(
filename
,
"r"
);
f
=
fopen
(
filename
,
"r"
);
if
(
f
==
NULL
){
if
(
f
==
NULL
){
logger
.
debug
(
"readPid - %s not found"
,
filename
);
return
-
1
;
/* File didn't exist */
return
-
1
;
/* File didn't exist */
}
}
...
@@ -358,7 +356,7 @@ CPCD::Process::start() {
...
@@ -358,7 +356,7 @@ CPCD::Process::start() {
switch
(
pid
=
fork
())
{
switch
(
pid
=
fork
())
{
case
0
:
/* Child */
case
0
:
/* Child */
setsid
();
setsid
();
writePid
(
getp
id
());
writePid
(
getp
grp
());
if
(
runas
(
m_runas
.
c_str
())
==
0
){
if
(
runas
(
m_runas
.
c_str
())
==
0
){
do_exec
();
do_exec
();
}
}
...
@@ -383,11 +381,10 @@ CPCD::Process::start() {
...
@@ -383,11 +381,10 @@ CPCD::Process::start() {
switch
(
fork
())
{
switch
(
fork
())
{
case
0
:
/* Child */
case
0
:
/* Child */
signal
(
SIGCHLD
,
SIG_IGN
);
signal
(
SIGCHLD
,
SIG_IGN
);
pid_t
pid
;
switch
(
pid
=
fork
())
{
switch
(
pid
=
fork
())
{
case
0
:
/* Child */
case
0
:
/* Child */
setsid
();
setsid
();
writePid
(
getp
id
());
writePid
(
getp
grp
());
if
(
runas
(
m_runas
.
c_str
())
!=
0
){
if
(
runas
(
m_runas
.
c_str
())
!=
0
){
_exit
(
1
);
_exit
(
1
);
}
}
...
@@ -421,13 +418,16 @@ CPCD::Process::start() {
...
@@ -421,13 +418,16 @@ CPCD::Process::start() {
logger
.
critical
(
"Unknown process type"
);
logger
.
critical
(
"Unknown process type"
);
return
-
1
;
return
-
1
;
}
}
while
(
readPid
()
<
0
){
while
(
readPid
()
<
0
){
sched_yield
();
sched_yield
();
}
}
if
(
pid
!=
-
1
&&
pid
!=
m_pid
){
errno
=
0
;
logger
.
error
(
"pid and m_pid don't match: %d %d"
,
pid
,
m_pid
);
pid_t
pgid
=
getpgid
(
pid
);
if
(
pgid
!=
-
1
&&
pgid
!=
m_pid
){
logger
.
error
(
"pgid and m_pid don't match: %d %d (%d)"
,
pgid
,
m_pid
,
pid
);
}
}
if
(
isRunning
()){
if
(
isRunning
()){
...
@@ -446,33 +446,32 @@ CPCD::Process::stop() {
...
@@ -446,33 +446,32 @@ CPCD::Process::stop() {
unlink
(
filename
);
unlink
(
filename
);
if
(
m_pid
<=
1
){
if
(
m_pid
<=
1
){
logger
.
critical
(
"Stopping process with bogus pid: %d"
,
m_pid
);
logger
.
critical
(
"Stopping process with bogus pid: %d id: %d"
,
m_pid
,
m_id
);
return
;
return
;
}
}
m_status
=
STOPPING
;
m_status
=
STOPPING
;
const
pid_t
pgid
=
-
getpgid
(
m_pid
)
;
errno
=
0
;
int
ret
=
kill
(
pg
id
,
SIGTERM
);
int
ret
=
kill
(
-
m_p
id
,
SIGTERM
);
switch
(
ret
)
{
switch
(
ret
)
{
case
0
:
case
0
:
logger
.
debug
(
"Sent SIGTERM to pid %d"
,
(
int
)
pg
id
);
logger
.
debug
(
"Sent SIGTERM to pid %d"
,
(
int
)
-
m_p
id
);
break
;
break
;
default:
default:
logger
.
debug
(
"kill pid: %d : %s"
,
(
int
)
pg
id
,
strerror
(
errno
));
logger
.
debug
(
"kill pid: %d : %s"
,
(
int
)
-
m_p
id
,
strerror
(
errno
));
break
;
break
;
}
}
errno
=
0
;
if
(
isRunning
()){
ret
=
kill
(
pgid
,
0
);
if
(
ret
==
0
)
{
errno
=
0
;
errno
=
0
;
ret
=
kill
(
pg
id
,
SIGKILL
);
ret
=
kill
(
-
m_p
id
,
SIGKILL
);
switch
(
ret
)
{
switch
(
ret
)
{
case
0
:
case
0
:
logger
.
debug
(
"Sent SIGKILL to pid %d"
,
(
int
)
pg
id
);
logger
.
debug
(
"Sent SIGKILL to pid %d"
,
(
int
)
-
m_p
id
);
break
;
break
;
default:
default:
logger
.
debug
(
"kill pid: %d : %s
\n
"
,
(
int
)
pg
id
,
strerror
(
errno
));
logger
.
debug
(
"kill pid: %d : %s
\n
"
,
(
int
)
-
m_p
id
,
strerror
(
errno
));
break
;
break
;
}
}
}
}
...
...
ndb/src/mgmclient/test_cpcd/test_cpcd.cpp
View file @
b886afc0
...
@@ -88,10 +88,16 @@ void define(){
...
@@ -88,10 +88,16 @@ void define(){
//proc.m_proc.m_stdout = "log.out";
//proc.m_proc.m_stdout = "log.out";
//proc.m_proc.m_stderr = "2>&1";
//proc.m_proc.m_stderr = "2>&1";
//proc.m_proc.m_runas = proc.m_host->m_user;
//proc.m_proc.m_runas = proc.m_host->m_user;
//proc.m_proc.m_ulimit = "c:unlimited";
m_proc
.
m_ulimit
=
"c:unlimited"
;
m_proc
.
m_name
.
assfmt
(
"%d-%d-%s"
,
getpid
(),
name
++
,
"test"
);
if
((
rand
()
&
15
)
>=
0
){
m_proc
.
m_path
.
assign
(
"/bin/sleep"
);
m_proc
.
m_name
.
assfmt
(
"%d-%d-%s"
,
getpid
(),
name
++
,
"sleep"
);
m_proc
.
m_args
=
"600"
;
m_proc
.
m_path
.
assign
(
"/bin/sleep"
);
m_proc
.
m_args
=
"600"
;
}
else
{
m_proc
.
m_name
.
assfmt
(
"%d-%d-%s"
,
getpid
(),
name
++
,
"test.sh"
);
m_proc
.
m_path
.
assign
(
"/home/jonas/run/cpcd/test.sh"
);
m_proc
.
m_args
=
"600"
;
}
g_procs
.
push_back
(
m_proc
);
g_procs
.
push_back
(
m_proc
);
Properties
reply
;
Properties
reply
;
...
...
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