summaryrefslogtreecommitdiff
path: root/sys/src/cmd/rc/subr.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2016-02-22 22:25:21 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2016-02-22 22:25:21 +0100
commit258fe87faf0a64947bb91c8ed93f8ea378a36f83 (patch)
treec0e683a2e9f080ac67f7fd6947483cde52deb4bd /sys/src/cmd/rc/subr.c
parenta9639c68947a9872cacd8a9629df097fe009503b (diff)
rc: terminate rc when exec fails, cleanup
The execexec() function should never return, as it irreversably changes the filedescriptor table for the new program. This means rc's internal filedesciptors for reading the script get implicitely closed and we cannot continue the rc interpreter when Execute() fails. So Execute() now sets the error status, and execexec() runs Xexit() in case Execute() returns.
Diffstat (limited to 'sys/src/cmd/rc/subr.c')
-rw-r--r--sys/src/cmd/rc/subr.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/sys/src/cmd/rc/subr.c b/sys/src/cmd/rc/subr.c
index ee5550a8d..0bdf99742 100644
--- a/sys/src/cmd/rc/subr.c
+++ b/sys/src/cmd/rc/subr.c
@@ -9,15 +9,14 @@ emalloc(long n)
void *p = Malloc(n);
if(p==0)
panic("Can't malloc %d bytes", n);
-/* if(err){ pfmt(err, "malloc %d->%p\n", n, p); flush(err); } /**/
return p;
}
void*
erealloc(void *p, long n)
{
- p = Realloc(p, n); /* botch, should be Realloc */
- if(p==0)
+ p = Realloc(p, n);
+ if(p==0 && n!=0)
panic("Can't realloc %d bytes\n", n);
return p;
}
@@ -25,7 +24,6 @@ erealloc(void *p, long n)
void
efree(void *p)
{
-/* pfmt(err, "free %p\n", p); flush(err); /**/
if(p)
free(p);
else pfmt(err, "free 0\n");