-
Notifications
You must be signed in to change notification settings - Fork 26
Support Reporting Running State and Alive Notifications for applications written in C #270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
NicolasFussberger
wants to merge
4
commits into
eclipse-score:main
Choose a base branch
from
etas-contrib:feature/support-c-apps
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
23fcf15
Bring back C function prototypes
NicolasFussberger 2c2aa11
Add example application for C-code
NicolasFussberger eac2394
Apply suggested interface changes
NicolasFussberger d273415
Merge branch 'main' into feature/support-c-apps
NicolasFussberger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # ******************************************************************************* | ||
| # Copyright (c) 2026 Contributors to the Eclipse Foundation | ||
| # | ||
| # See the NOTICE file(s) distributed with this work for additional | ||
| # information regarding copyright ownership. | ||
| # | ||
| # This program and the accompanying materials are made available under the | ||
| # terms of the Apache License Version 2.0 which is available at | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # ******************************************************************************* | ||
| load("@rules_cc//cc:defs.bzl", "cc_binary") | ||
|
|
||
| cc_binary( | ||
| name = "c_supervised_app", | ||
| srcs = [ | ||
| "main.c", | ||
| ], | ||
| linkopts = select({ | ||
| "@platforms//os:qnx": [ | ||
| "-lsocket", | ||
| ], | ||
| "@platforms//os:linux": [ | ||
| "-lpthread", | ||
| "-lrt", | ||
| ], | ||
| }), | ||
| visibility = ["//visibility:public"], | ||
| deps = [ | ||
| "//score/launch_manager:alive_cc", | ||
| "//score/launch_manager:lifecycle_cc", | ||
| ], | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /******************************************************************************** | ||
| * Copyright (c) 2026 Contributors to the Eclipse Foundation | ||
| * | ||
| * See the NOTICE file(s) distributed with this work for additional | ||
| * information regarding copyright ownership. | ||
| * | ||
| * This program and the accompanying materials are made available under the | ||
| * terms of the Apache License Version 2.0 which is available at | ||
| * https://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| ********************************************************************************/ | ||
|
|
||
| #include <signal.h> | ||
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
| #include <unistd.h> | ||
|
|
||
| #include <score/mw/lifecycle/alive.h> | ||
| #include <score/mw/lifecycle/report_running.h> | ||
|
|
||
| static volatile sig_atomic_t exit_requested = 0; | ||
|
|
||
| static void signal_handler(int signal) | ||
| { | ||
| if (signal == SIGINT || signal == SIGTERM) | ||
| { | ||
| exit_requested = 1; | ||
| } | ||
| } | ||
|
|
||
| int main(void) | ||
| { | ||
| signal(SIGINT, signal_handler); | ||
| signal(SIGTERM, signal_handler); | ||
|
|
||
| void* alive = score_lcm_alive_initialize("/example/instance"); | ||
| if (alive == NULL) | ||
| { | ||
| fprintf(stderr, "Failed to initialize alive instance\n"); | ||
| return EXIT_FAILURE; | ||
| } | ||
|
|
||
| if (score_lcm_report_running() != 0) | ||
| { | ||
| fprintf(stderr, "Failed to report running state\n"); | ||
| score_lcm_alive_deinitialize(alive); | ||
| return EXIT_FAILURE; | ||
| } | ||
|
|
||
| while (!exit_requested) | ||
| { | ||
| score_lcm_alive_report_alive(alive); | ||
| usleep(50000); | ||
| } | ||
|
|
||
| score_lcm_alive_deinitialize(alive); | ||
| return EXIT_SUCCESS; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.