Skip to content

Commit 1977339

Browse files
committed
feat(container): add function to get detached mode
Sometimes we need to know if the container is in detached mode. We add this public function to the container API. Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
1 parent 1470f80 commit 1977339

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

src/ocre/container.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,3 +710,13 @@ const char *ocre_container_get_image(const struct ocre_container *container)
710710

711711
return container->image;
712712
}
713+
714+
bool ocre_container_is_detached(struct ocre_container *container)
715+
{
716+
if (!container) {
717+
LOG_ERR("Invalid container");
718+
return false;
719+
}
720+
721+
return container->detached;
722+
}

src/ocre/include/ocre/container.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#ifndef OCRE_CONTAINER_H
99
#define OCRE_CONTAINER_H
1010

11+
#include <stdbool.h>
12+
1113
/**
1214
* @brief The possible status of a container
1315
*
@@ -165,4 +167,16 @@ int ocre_container_kill(struct ocre_container *container);
165167
*/
166168
int ocre_container_wait(struct ocre_container *container, int *status);
167169

170+
/**
171+
* @brief Get detached mode
172+
* @memberof ocre_container
173+
*
174+
* Detached containers run on background.
175+
*
176+
* @param container A pointer to the container to terminate
177+
*
178+
* @return true if container is detached, false otherwise
179+
*/
180+
bool ocre_container_is_detached(struct ocre_container *container);
181+
168182
#endif /* OCRE_CONTAINER_H */

0 commit comments

Comments
 (0)