Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
unix
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
tu-wien
unix
Commits
ff14545d
Commit
ff14545d
authored
Jan 13, 2019
by
Ivaylo Ivanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move the clean_up function and add it to generator
parent
696deabb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
25 deletions
+29
-25
fb_arc_set/generator.c
fb_arc_set/generator.c
+6
-1
fb_arc_set/shared/structs.c
fb_arc_set/shared/structs.c
+23
-0
fb_arc_set/supervisor.c
fb_arc_set/supervisor.c
+0
-24
No files found.
fb_arc_set/generator.c
View file @
ff14545d
...
@@ -42,6 +42,11 @@ int main(int argc, char *argv[]) {
...
@@ -42,6 +42,11 @@ int main(int argc, char *argv[]) {
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
if
(
atexit
(
clean_up
)
!=
0
)
{
fprintf
(
stderr
,
"ERROR: Cannot set exit function
\n
"
);
exit
(
EXIT_FAILURE
);
}
process_signal
();
process_signal
();
/// Create a regex to check the input against
/// Create a regex to check the input against
...
@@ -138,7 +143,7 @@ int main(int argc, char *argv[]) {
...
@@ -138,7 +143,7 @@ int main(int argc, char *argv[]) {
for
(
int
i
=
0
;
i
<
num_edges
;
i
++
)
{
for
(
int
i
=
0
;
i
<
num_edges
;
i
++
)
{
if
(
buf_edges
[
i
].
chosen
==
true
)
{
if
(
buf_edges
[
i
].
chosen
==
true
)
{
res
.
edge_num
++
;
res
.
edge_num
++
;
res
.
edges
[
--
new_best
]
=
edges
[
i
];
///< We begin counting from 0
res
.
edges
[
--
new_best
]
=
buf_
edges
[
i
];
///< We begin counting from 0
}
}
}
}
res
.
valid
=
true
;
res
.
valid
=
true
;
...
...
fb_arc_set/shared/structs.c
View file @
ff14545d
...
@@ -52,3 +52,26 @@ static void process_signal(void){
...
@@ -52,3 +52,26 @@ static void process_signal(void){
sigaction
(
SIGINT
,
&
sa
,
NULL
);
sigaction
(
SIGINT
,
&
sa
,
NULL
);
sigaction
(
SIGTERM
,
&
sa
,
NULL
);
sigaction
(
SIGTERM
,
&
sa
,
NULL
);
}
}
/**
* @brief Function to that cleans up the resources
* @details The function closes and destroys all semaphores,
* closes and destroys all shared memory objects and
* closes the file descriptors
* @param none
* @return none
**/
static
void
clean_up
(
void
)
{
/// Close and destory semaphores
close_sem
(
free_sem
);
close_sem
(
use_sem
);
close_sem
(
mutex
);
destroy_sem
(
FREE_SEM_NAME
);
destroy_sem
(
USE_SEM_NAME
);
destroy_sem
(
MUTEX_NAME
);
/// Close and destroy shared memory objects
close_shm
(
circ_buffer
,
sizeof
(
buffer_t
));
destroy_shm
(
BUFF_SHM_NAME
,
buffer_shmfd
);
}
fb_arc_set/supervisor.c
View file @
ff14545d
...
@@ -94,27 +94,3 @@ int main(int argc, char *argv[]) {
...
@@ -94,27 +94,3 @@ int main(int argc, char *argv[]) {
}
}
exit
(
EXIT_SUCCESS
);
exit
(
EXIT_SUCCESS
);
}
}
/**
* @brief Function to that cleans up the resources
* @details The function closes and destroys all semaphores,
* closes and destroys all shared memory objects and
* closes the file descriptors
* @param none
* @return none
**/
void
clean_up
(
void
)
{
/// Close and destory semaphores
close_sem
(
free_sem
);
close_sem
(
use_sem
);
close_sem
(
mutex
);
destroy_sem
(
FREE_SEM_NAME
);
destroy_sem
(
USE_SEM_NAME
);
destroy_sem
(
MUTEX_NAME
);
/// Close and destroy shared memory objects
close_shm
(
circ_buffer
,
sizeof
(
buffer_t
));
destroy_shm
(
BUFF_SHM_NAME
,
buffer_shmfd
);
}
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