* [PATCH] waitpid should not crash on error
@ 2011-10-16 3:57 Nala Ginrut
2011-10-17 17:00 ` Mark H Weaver
0 siblings, 1 reply; 4+ messages in thread
From: Nala Ginrut @ 2011-10-16 3:57 UTC (permalink / raw)
To: guile-devel
[-- Attachment #1.1: Type: text/plain, Size: 444 bytes --]
hi guys!
I realized that "waitpid" in Guile will cause my program crash while
"waitpid" actually returned -1. I believe it's unnecessary. I think the
better way is we deal with it by ourselves if "waitpid in POSIX" returned
-1. The SCM_SYSERROR bother me a lot. I hope my program get robustness other
than crash.
Yes I can wrap my own "waipid" for my program if no one get interested in
this patch. Just a suggestion. ;-)
What you guys think?
[-- Attachment #1.2: Type: text/html, Size: 541 bytes --]
[-- Attachment #2: 0001-waitpid-should-return-false-on-error.patch --]
[-- Type: text/x-patch, Size: 709 bytes --]
From 0e4b65ee6b8dfc6cfba01a9a91aa49babaa5d7c7 Mon Sep 17 00:00:00 2001
From: NalaGinrut <NalaGinrut@gmail.com>
Date: Sun, 16 Oct 2011 11:30:25 +0800
Subject: [PATCH] waitpid should return false on error
---
libguile/posix.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/libguile/posix.c b/libguile/posix.c
index 2923dc6..5b8f849 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -731,7 +731,7 @@ SCM_DEFINE (scm_waitpid, "waitpid", 1, 1, 0,
}
SCM_SYSCALL (i = waitpid (scm_to_int (pid), &status, ioptions));
if (i == -1)
- SCM_SYSERROR;
+ return SCM_BOOL_F;
return scm_cons (scm_from_int (i), scm_from_int (status));
}
#undef FUNC_NAME
--
1.7.0.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] waitpid should not crash on error
2011-10-16 3:57 [PATCH] waitpid should not crash on error Nala Ginrut
@ 2011-10-17 17:00 ` Mark H Weaver
2011-10-18 2:22 ` Nala Ginrut
0 siblings, 1 reply; 4+ messages in thread
From: Mark H Weaver @ 2011-10-17 17:00 UTC (permalink / raw)
To: Nala Ginrut; +Cc: guile-devel
Nala Ginrut <nalaginrut@gmail.com> writes:
> I realized that "waitpid" in Guile will cause my program crash while
> "waitpid" actually returned -1. I believe it's unnecessary. I think
> the better way is we deal with it by ourselves if "waitpid in POSIX"
> returned -1. The SCM_SYSERROR bother me a lot. I hope my program
> get robustness other than crash.
The proper way to deal with this is to catch the system error, e.g.:
(catch 'system-error
(lambda () (waitpid the-pid))
(lambda (key . args) 'waitpid-failed))
Best,
Mark
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] waitpid should not crash on error
2011-10-17 17:00 ` Mark H Weaver
@ 2011-10-18 2:22 ` Nala Ginrut
2011-10-18 14:58 ` Andy Wingo
0 siblings, 1 reply; 4+ messages in thread
From: Nala Ginrut @ 2011-10-18 2:22 UTC (permalink / raw)
To: Mark H Weaver, guile-devel
[-- Attachment #1: Type: text/plain, Size: 765 bytes --]
On Tue, Oct 18, 2011 at 1:00 AM, Mark H Weaver <mhw@netris.org> wrote:
> Nala Ginrut <nalaginrut@gmail.com> writes:
> > I realized that "waitpid" in Guile will cause my program crash while
> > "waitpid" actually returned -1. I believe it's unnecessary. I think
> > the better way is we deal with it by ourselves if "waitpid in POSIX"
> > returned -1. The SCM_SYSERROR bother me a lot. I hope my program
> > get robustness other than crash.
>
> The proper way to deal with this is to catch the system error, e.g.:
>
> (catch 'system-error
> (lambda () (waitpid the-pid))
> (lambda (key . args) 'waitpid-failed))
>
> Best,
> Mark
>
Oh thanks ,that's what I need.
But how can I find the error message like 'waitpid-failed? I can't find it
in the manual.
[-- Attachment #2: Type: text/html, Size: 1238 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] waitpid should not crash on error
2011-10-18 2:22 ` Nala Ginrut
@ 2011-10-18 14:58 ` Andy Wingo
0 siblings, 0 replies; 4+ messages in thread
From: Andy Wingo @ 2011-10-18 14:58 UTC (permalink / raw)
To: Nala Ginrut; +Cc: Mark H Weaver, guile-devel
On Tue 18 Oct 2011 04:22, Nala Ginrut <nalaginrut@gmail.com> writes:
> On Tue, Oct 18, 2011 at 1:00 AM, Mark H Weaver <mhw@netris.org> wrote:
>
> (catch 'system-error
> (lambda () (waitpid the-pid))
> (lambda (key . args) 'waitpid-failed))
>
> But how can I find the error message like 'waitpid-failed? I can't
> find it in the manual.
That's not an error message, it's the return value of the catch handler.
Andy
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-10-18 14:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-16 3:57 [PATCH] waitpid should not crash on error Nala Ginrut
2011-10-17 17:00 ` Mark H Weaver
2011-10-18 2:22 ` Nala Ginrut
2011-10-18 14:58 ` Andy Wingo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).