Re: [PATCH] script: preserve child exit status

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 Hi,

On Tue, Mar 03, 2009 at 12:19:03PM -0500, therealneworld@xxxxxxxxx wrote:
> I was working on a project and need the abilities of script to record
> the interaction but also needed to capture the exit status. I created

 this request makes sense

> this patch for script to perform that task and wanted to send it along
> in case you were interested in using it. Feel free to ask questions me
> any questions about the patch.
> 
> Add a new option, e, that preserves the child processes exit status
> and uses that as script's exit status.  It uses the same format as
> bash does, so if the process was killed by a signal the exit status
> will be 128+signal.
>
>@@ -202,13 +207,23 @@
> 	sa.sa_handler = finish;
> 	sigaction(SIGCHLD, &sa, NULL);
> 
>+	if(eflg)
>+		sighold(SIGCHLD);
> 	child = fork();
>+	if(eflg)
>+		sigrelse(SIGCHLD);
>+

 Why we need this SIGCHLD "decoration" around fork(2)? Note that
 sig{hold,relse} are obsolete.

> void
>@@ -436,6 +453,13 @@
> 		if (!qflg)
> 			printf(_("Script done, file is %s\n"), fname);
> 	}
>+
>+	if(eflg)
>+		if (WIFSIGNALED(childstatus))
>+			exit(WTERMSIG(childstatus) + 0x80);
>+		else
>+			exit(WEXITSTATUS(childstatus));
>+

 I guess it should be "if (eflg) { .... }".

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux