Bug 182148

Summary: "time -h portupgrade -aDFR -O" stops sending ^D
Product: Base System Reporter: Thomas Schweikle <tps>
Component: miscAssignee: freebsd-bugs (Nobody) <bugs>
Status: Open ---    
Severity: Affects Only Me    
Priority: Normal    
Version: 9.2-PRERELEASE   
Hardware: Any   
OS: Any   

Description Thomas Schweikle 2013-09-16 11:30:00 UTC
Having a script:
--- snip
#!/bin/sh

timecmd() {
  echo "$(date) -- \"$*\""
  time -h -- $*
  res=$?
  echo
  echo
  return $res
}

timecmd portupgrade -aDFR -O
--- snap

leads to output:
--- snip
# update up
Mon Sep 16 11:28:47 CEST 2013 -- "portupgrade -aDFR -O"
[Reading data from pkg(8) ... - 272 packages found - done]
--->  Fetching the distfile(s) for 'sqlite3-3.8.0.2' (databases/sqlite3)
--->  Fetching '/usr/ports/databases/sqlite3'
^D
--- snap

at this point the script stops. Changing it to read:
--- snip
#!/bin/sh

timecmd() {
  echo "$(date) -- \"$*\""
  time -h -- $*
  res=$?
  echo
  echo
  return $res
}

timecmd portupgrade -aDFR -O \< /dev/null
--- snap

leads to output:
--- snip
# update up
Mon Sep 16 12:22:51 CEST 2013 -- "portupgrade -aDFR -O < /dev/null"
[Reading data from pkg(8) ... - 272 packages found - done]
: date format error

--- snap

Looks like there is something going on inside portupgrade while fiddling with stdio/stderr/stdin giving strange results or leading to hanging processes waiting for input.

Fix: 

Do not use portupgrade with any io-redirects
Do not use "time" or others to execute portupgrade

So really: no fix known.
How-To-Repeat: Copy the above script, execute it to update ports database
Comment 1 tschweikle 2013-09-16 11:34:42 UTC
Fix must read: ... inside of scripts.

-- 
Thomas
Comment 2 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 07:58:53 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped