From andre.albsmeier@mchp.siemens.de  Tue Jan 23 22:41:55 2001
Return-Path: <andre.albsmeier@mchp.siemens.de>
Received: from goliath.siemens.de (goliath.siemens.de [194.138.37.131])
	by hub.freebsd.org (Postfix) with ESMTP id 97FB337B402
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 23 Jan 2001 22:41:54 -0800 (PST)
Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14])
	by goliath.siemens.de (8.11.0/8.11.0) with ESMTP id f0O6foC24442
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 24 Jan 2001 07:41:51 +0100 (MET)
Received: from curry.mchp.siemens.de (curry.mchp.siemens.de [139.25.42.7])
	by mail3.siemens.de (8.11.1/8.11.1) with ESMTP id f0O6flq20002044
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 24 Jan 2001 07:41:49 +0100 (MET)
Received: (from localhost)
	by curry.mchp.siemens.de (8.11.1/8.11.1) id f0O6fl650149
	for FreeBSD-gnats-submit@freebsd.org; Wed, 24 Jan 2001 07:41:47 +0100 (CET)
Message-Id: <200101240641.f0O6flo96164@curry.mchp.siemens.de>
Date: Wed, 24 Jan 2001 07:41:47 +0100 (CET)
From: Andre Albsmeier <andre.albsmeier@mchp.siemens.de>
To: FreeBSD-gnats-submit@freebsd.org
Subject: jobs command differs in interactive vs. non-interactive /bin/sh
X-Send-Pr-Version: 3.2

>Number:         24591
>Category:       bin
>Synopsis:       jobs command differs in interactive vs. non-interactive /bin/sh
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jan 23 22:50:00 PST 2001
>Closed-Date:    Sun Sep 2 16:16:45 PDT 2001
>Last-Modified:  Sun Sep 02 16:20:09 PDT 2001
>Originator:     Andre Albsmeier
>Release:        FreeBSD 4.2-STABLE i386
>Organization:
>Environment:

FreeBSD 4.2-STABLE

>Description:

When the 'jobs' command is used in /bin/sh, its output differs
depending if sh is an interactive vs. non-interactive shell.


>How-To-Repeat:

andre@bali:~>/bin/sh 
$ sleep 10 &
$ jobs
[1] 76401                     sleep 10
$ 

vs.

andre@bali:~>cat jobstest 
#!/bin/sh
sleep 10 &
jobs
andre@bali:~>./jobstest 
[1] 76411                     


In an interactive shell, name and args of the backgrounded command
are printed. These are missing in the case of the non-interactive shell.

>Fix:

Unknown. In /src/bin/sh/jobs.c,v 1.27.2.2 in line 337, the code

	out1str(ps->cmd);

normally outputs the command which doesn't work in non-interactive shells.


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: jon 
State-Changed-When: Sun Sep 2 16:16:45 PDT 2001 
State-Changed-Why:  
If you want a shell that behaves the same way as an interactive shell, 
start sh with the -i flag. 

The reason this does not work in non-interactive mode is because the command 
string is not stored unless the shell is an interactive root shell. 
See jobs.c line 678: 
if (iflag && rootshell && n) 
ps->cmd = commandtext(n); 



http://www.FreeBSD.org/cgi/query-pr.cgi?pr=24591 
>Unformatted:
