ref: af7c8671be2b7c480ab5fac4aeb3e7c2859ab48d
parent: 10522cecea250586efa3bda353f555211bef3a67
author: Jacob Moody <moody@posixcafe.org>
date: Sat Apr 19 17:49:05 EDT 2025
sam: fix incorrect exit status from shell subproc
--- a/sys/src/cmd/sam/shell.c
+++ b/sys/src/cmd/sam/shell.c
@@ -46,7 +46,6 @@
long l;
int m;
int pid, fd;
- int retcode;
char *retmsg;
int pipe1[2], pipe2[2];
@@ -96,20 +95,21 @@
*/
close(pipe2[0]);
io = pipe2[1];
- if(retcode=!setjmp(mainloop)){ /* assignment = */
- char *c;
- for(l = 0; l<plan9buf.nc; l+=m){
- m = plan9buf.nc-l;
- if(m>BLOCKSIZE-1)
- m = BLOCKSIZE-1;
- bufread(&plan9buf, l, genbuf, m);
- genbuf[m] = 0;
- c = Strtoc(tmprstr(genbuf, m+1));
- Write(pipe2[1], c, strlen(c));
- free(c);
- }
+ if(setjmp(mainloop))
+ exits("error");
+
+ char *c;
+ for(l = 0; l<plan9buf.nc; l+=m){
+ m = plan9buf.nc-l;
+ if(m>BLOCKSIZE-1)
+ m = BLOCKSIZE-1;
+ bufread(&plan9buf, l, genbuf, m);
+ genbuf[m] = 0;
+ c = Strtoc(tmprstr(genbuf, m+1));
+ Write(pipe2[1], c, strlen(c));
+ free(c);
}
- exits(retcode? "error" : 0);
+ exits(nil);
}
if(pid==-1){
fprint(2, "Can't fork?!\n");
--
⑨