Skip to content
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

Block on application using uk_posix_process_wait() #74

Open
wants to merge 1 commit into
base: staging
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,17 +234,21 @@ int main(int argc, char *argv[])
argc, argv, environ, rand);
app_thread->flags |= UK_THREADF_RUNNABLE;
#if CONFIG_LIBPOSIX_PROCESS
uk_posix_process_create(uk_alloc_get_default(),
app_thread,
uk_thread_current());
ret = uk_posix_process_create(uk_alloc_get_default(),
app_thread,
uk_thread_current());
if (unlikely(ret)) {
uk_pr_err("Could not create application process: %d\n", ret);
return ret;
}
#endif
uk_pr_debug("%s: Application stack at %p - %p, pointer: %p\n",
progname,
(void *) app_thread->_mem.stack,
(void *) ((uintptr_t) app_thread->_mem.stack
+ PAGES2BYTES(CONFIG_APPELFLOADER_STACK_NBPAGES)),
(void *) app_thread->ctx.sp);
uk_pr_debug("%s: Application entrance at %p\n",
uk_pr_debug("%s: Application entry at %p\n",
progname,
(void *) app_thread->ctx.ip);

Expand All @@ -253,15 +257,16 @@ int main(int argc, char *argv[])
*/
uk_sched_thread_add(uk_sched_current(), app_thread);

#if CONFIG_LIBPOSIX_PROCESS
/*
* FIXME: Instead of an infinite wait, wait for application
* to exit (this needs thread_wait support with
* uksched and/or posix-process)
* Wait for application to exit
*/
ret = uk_posix_process_wait();
goto out;
#else /* !CONFIG_LIBPOSIX_PROCESS */
for (;;)
sleep(10);

/* TODO: As soon as we are able to return: properly exit/shutdown */
#endif /* !CONFIG_LIBPOSIX_PROCESS */

out_free_thread:
uk_thread_release(app_thread);
Expand Down