Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
dba21fbf
Commit
dba21fbf
authored
Jun 14, 2014
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(extensions): вынес общий код функцит on_sigchild(..);
(ожидание завершения дочерних потоков)
parent
3e5e880b
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
30 additions
and
38 deletions
+30
-38
main.cc
extensions/ModbusMaster/main.cc
+2
-3
multi-main.cc
extensions/ModbusMaster/multi-main.cc
+2
-3
rtuexchange.cc
extensions/ModbusMaster/rtuexchange.cc
+2
-3
mbslave.cc
extensions/ModbusSlave/mbslave.cc
+2
-3
mbtcp-multislave.cc
extensions/ModbusSlave/mbtcp-multislave.cc
+2
-3
smemory.cc
extensions/SharedMemory/smemory.cc
+0
-2
smemory-plus.cc
extensions/SharedMemoryPlus/smemory-plus.cc
+0
-13
unetexchange.cc
extensions/UNetUDP/unetexchange.cc
+2
-3
uninet.cc
extensions/UniNetwork/uninet.cc
+2
-3
Extensions.h
extensions/include/Extensions.h
+3
-0
Extensions.cc
extensions/lib/Extensions.cc
+13
-1
ModbusTCPMaster.cc
src/Communications/Modbus/ModbusTCPMaster.cc
+0
-1
No files found.
extensions/ModbusMaster/main.cc
View file @
dba21fbf
#include <sys/wait.h>
#include <sstream>
#include "MBTCPMaster.h"
#include "Configuration.h"
...
...
@@ -70,7 +69,7 @@ int main( int argc, const char** argv )
dlog
<<
"
\n\n\n
"
;
dlog
<<
"(main): -------------- MBTCP Exchange START -------------------------
\n\n
"
;
act
->
run
(
false
);
while
(
waitpid
(
-
1
,
0
,
0
)
>
0
);
on_sigchild
(
SIGTERM
);
return
0
;
}
catch
(
Exception
&
ex
)
...
...
@@ -82,6 +81,6 @@ int main( int argc, const char** argv )
dcrit
<<
"(mbtcpmaster): catch ..."
<<
std
::
endl
;
}
while
(
waitpid
(
-
1
,
0
,
0
)
>
0
);
on_sigchild
(
SIGTERM
);
return
1
;
}
extensions/ModbusMaster/multi-main.cc
View file @
dba21fbf
#include <sys/wait.h>
#include <sstream>
#include "MBTCPMultiMaster.h"
#include "Configuration.h"
...
...
@@ -71,7 +70,7 @@ int main( int argc, const char** argv )
dlog
<<
"(main): -------------- MBTCPMulti Exchange START -------------------------
\n\n
"
;
act
->
run
(
false
);
while
(
waitpid
(
-
1
,
0
,
0
)
>
0
);
on_sigchild
(
SIGTERM
);
return
0
;
}
...
...
@@ -84,6 +83,6 @@ int main( int argc, const char** argv )
dcrit
<<
"(mbtcpmultimaster): catch ..."
<<
std
::
endl
;
}
while
(
waitpid
(
-
1
,
0
,
0
)
>
0
);
on_sigchild
(
SIGTERM
);
return
1
;
}
extensions/ModbusMaster/rtuexchange.cc
View file @
dba21fbf
#include <sys/wait.h>
#include <sstream>
#include "UniSetActivator.h"
#include "Extensions.h"
...
...
@@ -70,7 +69,7 @@ int main( int argc, char** argv )
act
->
run
(
false
);
while
(
waitpid
(
-
1
,
0
,
0
)
>
0
);
on_sigchild
(
SIGTERM
);
return
0
;
}
catch
(
Exception
&
ex
)
...
...
@@ -82,6 +81,6 @@ int main( int argc, char** argv )
dcrit
<<
"(rtuexchange): catch ..."
<<
std
::
endl
;
}
while
(
waitpid
(
-
1
,
0
,
0
)
>
0
);
on_sigchild
(
SIGTERM
);
return
1
;
}
extensions/ModbusSlave/mbslave.cc
View file @
dba21fbf
// --------------------------------------------------------------------------
#include <sys/wait.h>
#include <sstream>
#include <string>
#include <cc++/socket.h>
...
...
@@ -75,7 +74,7 @@ int main(int argc, const char **argv)
dlog
<<
"(main): -------------- MBSlave START -------------------------
\n\n
"
;
act
->
run
(
false
);
while
(
waitpid
(
-
1
,
0
,
0
)
>
0
);
on_sigchild
(
SIGTERM
);
return
0
;
}
catch
(
SystemError
&
err
)
...
...
@@ -95,7 +94,7 @@ int main(int argc, const char **argv)
dcrit
<<
"(mbslave): catch(...)"
<<
endl
;
}
while
(
waitpid
(
-
1
,
0
,
0
)
>
0
);
on_sigchild
(
SIGTERM
);
return
1
;
}
// --------------------------------------------------------------------------
extensions/ModbusSlave/mbtcp-multislave.cc
View file @
dba21fbf
// --------------------------------------------------------------------------
#include <sys/wait.h>
#include <sstream>
#include <string>
#include <cc++/socket.h>
...
...
@@ -75,7 +74,7 @@ int main(int argc, const char **argv)
dlog
<<
"(main): -------------- MBTCPMultiSlave START -------------------------
\n\n
"
;
act
->
run
(
false
);
while
(
waitpid
(
-
1
,
0
,
0
)
>
0
);
on_sigchild
(
SIGTERM
);
return
0
;
}
catch
(
SystemError
&
err
)
...
...
@@ -95,7 +94,7 @@ int main(int argc, const char **argv)
dcrit
<<
"(mbslave): catch(...)"
<<
endl
;
}
while
(
waitpid
(
-
1
,
0
,
0
)
>
0
);
on_sigchild
(
SIGTERM
);
return
1
;
}
// --------------------------------------------------------------------------
extensions/SharedMemory/smemory.cc
View file @
dba21fbf
...
...
@@ -38,8 +38,6 @@ int main(int argc, const char **argv)
SystemMessage
sm
(
SystemMessage
::
StartUp
);
act
->
broadcast
(
sm
.
transport_msg
()
);
act
->
run
(
false
);
// pause(); // пауза, чтобы дочерние потоки успели завершить работу
return
0
;
}
catch
(
SystemError
&
err
)
...
...
extensions/SharedMemoryPlus/smemory-plus.cc
View file @
dba21fbf
// --------------------------------------------------------------------------
#include <string>
#include <sys/wait.h>
#include <error.h>
#include <errno.h>
#include <Debug.h>
...
...
@@ -22,18 +21,6 @@ using namespace UniSetExtensions;
// --------------------------------------------------------------------------
const
int
MaxAddNum
=
10
;
// --------------------------------------------------------------------------
void
on_sigchild
(
int
sig
)
{
// while( waitpid(0,NULL,WNOHANG) > 0 ){}
while
(
1
)
{
int
istatus
;
pid_t
pid
=
waitpid
(
-
1
,
&
istatus
,
WNOHANG
);
if
(
pid
==
-
1
&&
errno
==
EINTR
)
continue
;
if
(
pid
<=
0
)
break
;
}
}
// --------------------------------------------------------------------------
static
void
help_print
(
int
argc
,
const
char
*
argv
[]
);
// --------------------------------------------------------------------------
int
main
(
int
argc
,
const
char
**
argv
)
...
...
extensions/UNetUDP/unetexchange.cc
View file @
dba21fbf
#include <sstream>
#include <sys/wait.h>
#include "UniSetActivator.h"
#include "Extensions.h"
#include "UNetExchange.h"
...
...
@@ -68,7 +67,7 @@ int main( int argc, const char** argv )
dlog
<<
"(main): -------------- UDPReceiver START -------------------------
\n\n
"
;
act
->
run
(
false
);
while
(
waitpid
(
-
1
,
0
,
0
)
>
0
);
on_sigchild
(
SIGTERM
);
}
catch
(
Exception
&
ex
)
{
...
...
@@ -79,6 +78,6 @@ int main( int argc, const char** argv )
dcrit
<<
"(unetexchange): catch ..."
<<
std
::
endl
;
}
while
(
waitpid
(
-
1
,
0
,
0
)
>
0
);
on_sigchild
(
SIGTERM
);
return
0
;
}
extensions/UniNetwork/uninet.cc
View file @
dba21fbf
#include <sys/wait.h>
#include <string>
#include "Debug.h"
#include "UniSetActivator.h"
...
...
@@ -53,7 +52,7 @@ int main(int argc, const char **argv)
act
->
broadcast
(
sm
.
transport_msg
()
);
act
->
run
(
true
);
shm
->
execute
();
while
(
waitpid
(
-
1
,
0
,
0
)
>
0
);
on_sigchild
(
SIGTERM
);
return
0
;
}
catch
(
SystemError
&
err
)
...
...
@@ -69,6 +68,6 @@ int main(int argc, const char **argv)
dlog
.
crit
()
<<
"(uninetwork): catch(...)"
<<
endl
;
}
while
(
waitpid
(
-
1
,
0
,
0
)
>
0
);
on_sigchild
(
SIGTERM
);
return
1
;
}
extensions/include/Extensions.h
View file @
dba21fbf
...
...
@@ -28,6 +28,9 @@ namespace UniSetExtensions
/*! Загрузка калибровочной диаграммы */
Calibration
*
buildCalibrationDiagram
(
const
std
::
string
&
dname
);
void
on_sigchild
(
int
sig
);
extern
DebugStream
dlog
;
}
// -------------------------------------------------------------------------
...
...
extensions/lib/Extensions.cc
View file @
dba21fbf
#include <sstream>
#include <string>
#include <sys/wait.h>
#include "Configuration.h"
#include "Extensions.h"
// -------------------------------------------------------------------------
...
...
@@ -128,6 +129,17 @@ namespace UniSetExtensions
return
new
Calibration
(
dnode
);
}
// -------------------------------------------------------------------------
void
on_sigchild
(
int
sig
)
{
while
(
1
)
{
int
istatus
;
pid_t
pid
=
waitpid
(
-
1
,
&
istatus
,
WNOHANG
);
if
(
pid
==
-
1
&&
errno
==
EINTR
)
continue
;
if
(
pid
<=
0
)
break
;
}
}
// --------------------------------------------------------------------------
}
// end of namespace
// -------------------------------------------------------------------------
src/Communications/Modbus/ModbusTCPMaster.cc
View file @
dba21fbf
...
...
@@ -360,7 +360,6 @@ void ModbusTCPMaster::connect( ost::InetAddress addr, int _port )
ost
::
Thread
::
setException
(
ost
::
Thread
::
throwException
);
try
{
ostringstream
aa
;
tcp
=
new
UTCPStream
();
tcp
->
create
(
iaddr
,
port
,
true
,
500
);
tcp
->
setTimeout
(
replyTimeOut_ms
);
...
...
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