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

unbreak system in a thread that has interrupts disabled #766

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions c/prim5.c
Original file line number Diff line number Diff line change
Expand Up @@ -711,9 +711,9 @@ static void s_showalloc(IBOOL show_dump, const char *outfn) {

static ptr s_system(const char *s) {
INT status;
char *s_arg;
#ifdef PTHREADS
ptr tc = get_thread_context();
char *s_arg = NULL;
#endif

#ifdef PTHREADS
Expand All @@ -725,11 +725,11 @@ static ptr s_system(const char *s) {
S_error("system", "malloc failed");
memcpy(s_arg, s, len);
deactivate_thread(tc);
}
#else
s_arg = (char *)s;
s = s_arg;
} else
s_arg = NULL;
#endif
status = SYSTEM(s_arg);
status = SYSTEM(s);
#ifdef PTHREADS
if (DISABLECOUNT(tc) == FIX(0)) {
reactivate_thread(tc);
Expand Down
5 changes: 5 additions & 0 deletions mats/unix.ms
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,11 @@
(unless (or (windows?)
(not (threaded?)))
(mat thread-system

;; make sure `system` works when interrupts are disabled
(with-interrupts-disabled
(eqv? 0 (system "echo hi")))

;; check that when a thread is deactivated during `system`,
;; the command that it's running isn't GCed
(let* ([count 50]
Expand Down