Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 278895 - detect orphaned processes (sys-devel/gcc:hang during emerging)
Summary: detect orphaned processes (sys-devel/gcc:hang during emerging)
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
: 306265 (view as bug list)
Depends on:
Blocks: 184128 257279 335925
  Show dependency tree
 
Reported: 2009-07-24 02:59 UTC by yegle
Modified: 2010-10-20 15:29 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
qlop -l output (qlop,337.24 KB, text/plain)
2009-07-28 07:17 UTC, yegle
Details
make ebuild.sh clean up orphaned processes (cleanup_orphans.patch,2.02 KB, patch)
2009-07-30 07:35 UTC, Zac Medico
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description yegle 2009-07-24 02:59:18 UTC
weird problem:
My laptop haven't been upgraded for a month. Recently I start to upgrade packages to the latest version.
When upgrading gcc, just after the message ">>>>source compiled", no more output from the terminal,it just hang for more than 1 hour.

I checked the process list:
root      6739  5409  0 16:13 pts/3    00:00:49 /usr/bin/python /usr/bin/emerge --update --newuse --deep @system @world
root     22140  6739  0 16:21 pts/3    00:00:00 [sandbox] <defunct>

I even tried many different gcc version like 4.3.2-r4,4.3.3-r2,4.4.0-r1,4.4.1,they all hangs during emerge

one more hint:this bug is a little like bug #186278 http://bugs.gentoo.org/186278

Reproducible: Always

Steps to Reproduce:
1.emerge gcc (as far as I know,any version)
2.wait ,patiently...
3.you got it ...




Portage 2.2_rc33 (default/linux/x86/2008.0, gcc-4.3.3, glibc-2.10.1-r0, 2.6.30-gentoo-r1-yegle i686)
=================================================================
System uname: Linux-2.6.30-gentoo-r1-yegle-i686-Intel-R-_Core-TM-2_CPU_T5600_@_1.83GHz-with-gentoo-2.0.1
Timestamp of tree: Fri, 24 Jul 2009 00:00:20 +0000
distcc[12232] (dcc_set_trace_from_env) ERROR: failed to open logfile /home/yegle/temp/distcc.log: Permission denied [disabled]
app-shells/bash:     4.0_p24
dev-java/java-config: 2.1.8-r1
dev-lang/python:     2.6.2-r1
dev-util/cmake:      2.6.4
sys-apps/baselayout: 2.0.1
sys-apps/openrc:     0.4.3-r3
sys-apps/sandbox:    2.0
sys-devel/autoconf:  2.13, 2.63-r1
sys-devel/automake:  1.7.9-r1, 1.9.6-r2, 1.10.2, 1.11
sys-devel/binutils:  2.19.1-r1
sys-devel/gcc-config: 1.4.1
sys-devel/libtool:   2.2.6a
virtual/os-headers:  2.6.30
ACCEPT_KEYWORDS="x86 ~x86"
ALSA_CARDS="hda-intel"
ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol"
ANT_HOME="/usr/share/ant"
APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias"
ARCH="x86"
AUTOCLEAN="yes"
BUILD_PREFIX="/home/yegle/temp/portage"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O2 -pipe -march=core2"
CHOST="i686-pc-linux-gnu"
CLEAN_DELAY="5"
COLLISION_IGNORE="/lib/modules"
COLON_SEPARATED="XDG_DATA_DIRS XDG_CONFIG_DIRS"
COLORFGBG="15;0"
CONFIG_PROTECT="/etc /usr/share/config"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/udev/rules.d"
CVS_RSH="ssh"
CXXFLAGS="-O2 -pipe -march=core2"
DBUS_SESSION_BUS_ADDRESS="unix:abstract=/tmp/dbus-HWaFSAFtux,guid=fe8f54deebf6f1c1053d83bc4a68b578"
DCCC_PATH="/usr/lib/distcc/bin"
DESKTOP_SESSION="KDE-4"
DESKTOP_STARTUP_ID=""
DISPLAY=":0"
DISTCC_LOG="/home/yegle/temp/distcc.log"
DISTCC_VERBOSE="0"
DISTDIR="/home/yegle/.distfiles"
DM_CONTROL="/var/run/xdmctl"
EDITOR="/bin/nano"
ELIBC="glibc"
EMERGE_DEFAULT_OPTS="-av --keep-going"
EMERGE_WARNING_DELAY="10"
FEATURES="collision-protect distlocks fixpackages metadata-transfer parallel-fetch preserve-libs protect-owned sandbox sfperms strict unmerge-orphans userfetch"
FETCHCOMMAND="/usr/bin/wget -t 5 -T 60 --passive-ftp -O "${DISTDIR}/${FILE}" "${URI}""
GCC_SPECS=""
GDK_USE_XFT="1"
GENTOO_MIRRORS=" http://distfiles.gentoo.org"
GS_LIB="/home/yegle/.fonts"
GTK2_RC_FILES="/etc/gtk-2.0/gtkrc:/home/yegle/.gtkrc-2.0:/home/yegle/.gtkrc-2.0-kde4:/home/yegle/.kde4/share/config/gtkrc-2.0"
GTK_IM_MODULE="scim"
GTK_RC_FILES="/etc/gtk/gtkrc:/home/yegle/.gtkrc::/home/yegle/.kde4/share/config/gtkrc"
HG="/usr/bin/hg"
HISTTIMEFORMAT="%F %T "
HOME="/home/yegle"
INFOPATH="/usr/share/info:/usr/share/binutils-data/i686-pc-linux-gnu/2.19.1/info:/usr/share/gcc-data/i486-pc-linux-gnu/4.1.2/info:/usr/share/gcc-data/i686-pc-linux-gnu/4.3.3/info:~/.texlive/2008/texmf/doc/info:~/.texlive/2008/texmf/doc/info"
INPUT_DEVICES="keyboard mouse synaptics evdev"
JAVAC="/home/yegle/.gentoo/java-config-2/current-user-vm/bin/javac"
JAVA_HOME="/home/yegle/.gentoo/java-config-2/current-user-vm"
JDK_HOME="/home/yegle/.gentoo/java-config-2/current-user-vm"
KDE_FULL_SESSION="true"
KDE_MULTIHEAD="false"
KDE_SESSION_UID="1000"
KDE_SESSION_VERSION="4"
KERNEL="linux"
KONSOLE_DBUS_SERVICE=":1.24"
KONSOLE_DBUS_SESSION="/Sessions/31"
LANG="zh_CN.UTF-8"
LANGUAGE=""
LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text"
LC_ALL="zh_CN.UTF-8"
LDFLAGS="-Wl,-O1"
LDPATH="/usr/local/lib:/usr/lib/opengl/nvidia/lib:/usr/i686-pc-linux-gnu/lib:/usr/lib/gcc/i486-pc-linux-gnu/4.1.2:/usr/lib/gcc/i686-pc-linux-gnu/4.3.3:/opt/intel/cc/10.1.018/lib:/usr/lib/nspr:/usr/lib/nss:/usr/lib/xulrunner-1.9.1:/usr/lib/qca2:/usr/lib/qt4:/usr/games/lib"
LESS="-R -M --shift 5"
LESSOPEN="|lesspipe.sh %s"
LINGUAS="en zh zh_CN"
LOGNAME="yegle"
LS_COLORS="rs=0:di=01;34:ln=01;36:hl=44;37:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.pdf=00;32:*.ps=00;32:*.txt=00;32:*.patch=00;32:*.diff=00;32:*.log=00;32:*.tex=00;32:*.doc=00;32:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:"
MAKEOPTS="-j1"
MALLOC_CHECK_="2"
MANPATH="/home/yegle/.gentoo/java-config-2/current-user-vm/man:/usr/local/share/man:/usr/share/man:/usr/share/binutils-data/i686-pc-linux-gnu/2.19.1/man:/usr/share/gcc-data/i486-pc-linux-gnu/4.1.2/man:/usr/share/gcc-data/i686-pc-linux-gnu/4.3.3/man:/opt/intel/cc/10.1.018/man:/etc/java-config/system-vm/man/:/usr/lib/php5/man/:/opt/opera/share/man:~/.texlive/2008/texmf/doc/man:~/.texlive/2008/texmf/doc/man"
NETBEANS="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml"
NOCOLOR="false"
OPENGL_PROFILE="nvidia"
PAGER="/usr/bin/less"
PATH="/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i486-pc-linux-gnu/gcc-bin/4.1.2:/usr/i686-pc-linux-gnu/gcc-bin/4.3.3:/opt/intel/cc/10.1.018/bin:/usr/games/bin:~/.bin/:~/.bin/"
PKGDIR="/usr/portage/packages"
PORTAGE_ARCHLIST="ppc x86-openbsd ppc-openbsd ppc64 x86-winnt x86-fbsd ppc-aix alpha arm x86-freebsd s390 amd64 x86-macos x64-openbsd ia64-hpux hppa x86-netbsd amd64-linux ia64-linux x86 sparc-solaris x64-freebsd sparc64-solaris x86-linux x64-macos sparc m68k-mint ia64 mips ppc-macos x86-interix hppa-hpux amd64-fbsd x64-solaris mips-irix m68k sh x86-solaris sparc-fbsd"
PORTAGE_BINHOST_CHUNKSIZE="3000"
PORTAGE_BIN_PATH="/usr/lib/portage/bin"
PORTAGE_COMPRESS_EXCLUDE_SUFFIXES="css gif htm[l]? jp[e]?g js pdf png"
PORTAGE_CONFIGROOT="/"
PORTAGE_DEBUG="0"
PORTAGE_DEPCACHEDIR="/var/cache/edb/dep"
PORTAGE_ECLASS_WARNING_ENABLE="0"
PORTAGE_ELOG_CLASSES="log warn error"
PORTAGE_ELOG_MAILFROM="portage@localhost"
PORTAGE_ELOG_MAILSUBJECT="[portage] ebuild log for ${PACKAGE} on ${HOST}"
PORTAGE_ELOG_MAILURI="root"
PORTAGE_ELOG_SYSTEM="save_summary echo"
PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS="5"
PORTAGE_FETCH_RESUME_MIN_SIZE="350K"
PORTAGE_GID="250"
PORTAGE_INST_GID="0"
PORTAGE_INST_UID="0"
PORTAGE_NICENESS="20"
PORTAGE_PYM_PATH="/usr/lib/portage/pym"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_RSYNC_RETRIES="3"
PORTAGE_TMPDIR="/home/yegle/temp"
PORTAGE_VERBOSE="1"
PORTAGE_WORKDIR_MODE="0700"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage/layman/gentoo-china /usr/local/portage/layman/gentoo-taiwan /usr/local/portage/layman/kde-testing /usr/local/portage/layman/x11 /usr/local/portage/layman/mozilla /usr/local/portage/layman/games /usr/local/portage/layman/enlightenment /usr/local/portage/layman/voyageur /usr/local/portage/layman/lxde /usr/local/portage/layman/jokey /usr/local/portage/layman/sunrise /home/yegle/portage"
PRELINK_PATH_MASK="/usr/lib/klibc"
PROFILEHOME=""
PROFILE_ONLY_VARIABLES="ARCH ELIBC KERNEL USERLAND"
PROMPT_COMMAND="history -a;echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007""
PWD="/home/yegle"
QT_IM_MODULE="scim"
QT_PLUGIN_PATH="/home/yegle/.kde4/lib/kde4/plugins/:/usr/lib/kde4/plugins/"
RESUMECOMMAND="/usr/bin/wget -c -t 5 -T 60 --passive-ftp -O "${DISTDIR}/${FILE}" "${URI}""
ROOT="/"
ROOTPATH="/opt/bin:/usr/i486-pc-linux-gnu/gcc-bin/4.1.2:/usr/i686-pc-linux-gnu/gcc-bin/4.3.3:/opt/intel/cc/10.1.018/bin"
RPMDIR="/usr/portage/rpm"
SESSION_MANAGER="local/localhost:@/tmp/.ICE-unix/5375,unix/localhost:/tmp/.ICE-unix/5375"
SGML_CATALOG_FILES="/etc/sgml/sgml-ent.cat:/etc/sgml/xml-docbook-4.1.2.cat:/etc/sgml/dsssl-docbook-stylesheets.cat:/etc/sgml/sgml-docbook-3.0.cat:/etc/sgml/sgml-docbook.cat:/etc/sgml/sgml-docbook-3.1.cat:/etc/sgml/openjade-1.3.2.cat:/etc/sgml/xml-docbook-4.4.cat:/etc/sgml/xml-docbook-4.2.cat:/etc/sgml/sgml-lite.cat:/etc/sgml/sgml-docbook-4.1.cat:/etc/sgml/sgml-docbook-4.0.cat:/etc/sgml/xml-docbook-4.5.cat"
SHELL="/bin/bash"
SHLVL="2"
STRIGI_PLUGIN_PATH="/usr/lib/strigi:"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
TERM="xterm"
TZ="Asia/Shanghai"
USE="X a52 aac aalib accessibility acpi alsa ass avahi bash-completion berkdb bluetooth bzip2 cairo cdda cddb cdparanoia cdr cjk cli clickurl consolekit cracklib crypt cscope cue curl custom-optimization daemon dbus dts dvd embedded enca encode exif ffmpeg flac fontconfig gcj gd gdbm geoip gif git glib gnutls gpm gtk hal iconv imlib ipv6 isdnlog ithreads jabber java javascript jpeg kde4 lame libnotify lyrics magic matroska mdnsresponder-compat midi mikmod mime mmx mp3 mp3tunes mpd mpeg msn mudflap ncurses network nptl nptlonly nsplugin nvidia ogg opengl openmp pam pch pcre pdf perl pinyin plasma png pppd prediction python qq qt3support qt4 quicktime rdesktop readline realmedia reflection remote rtsp scrobbler session spl sql sqlite srt sse sse2 sse3 ssl ssse3 startup-notification stats subversion svg symlink sysfs taglib tcpd templates test-programs theora truetype unicode upnp usb vim-syntax vim-with-x vorbis webkit wifi win32codecs wmp x264 x86 xcb xcomposite xmlrpc xorg xosd xulrunner xvid zlib" ALSA_CARDS="hda-intel" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="keyboard mouse synaptics evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en zh zh_CN" USERLAND="GNU" VIDEO_CARDS="nvidia"
USER="yegle"
USERLAND="GNU"
USE_EXPAND="ALSA_CARDS ALSA_PCM_PLUGINS APACHE2_MODULES APACHE2_MPMS CAMERAS CROSSCOMPILE_OPTS DVB_CARDS ELIBC FCDSL_CARDS FOO2ZJS_DEVICES FRITZCAPI_CARDS INPUT_DEVICES KERNEL LCD_DEVICES LINGUAS LIRC_DEVICES MISDN_CARDS NETBEANS_MODULES QEMU_SOFTMMU_TARGETS QEMU_USER_TARGETS SANE_BACKENDS USERLAND VIDEO_CARDS"
USE_EXPAND_HIDDEN="CROSSCOMPILE_OPTS ELIBC KERNEL USERLAND"
USE_ORDER="env:pkg:conf:defaults:pkginternal:env.d"
VIDEO_CARDS="nvidia"
WINDOWID="41943067"
WINDOWPATH="7"
XCURSOR_THEME="Oxygen_Blue"
XDG_CONFIG_DIRS="/etc/xdg"
XDG_DATA_DIRS="/usr/share:/usr/local/share:/usr/share"
XDG_MENU_PREFIX="kde-4.3-"
XDG_SESSION_COOKIE="69e6f6f987096262f64f4fe848c17097-1248376184.259198-1892494686"
XDM_MANAGED="method=classic"
XMODIFIERS="@im=SCIM"
_="/usr/bin/emerge"
Comment 1 Wormo (RETIRED) gentoo-dev 2009-07-26 23:22:34 UTC
Would you do 'ps axf' when it is hung, and show all child processes of your emerge -- there really ought to be more than just the defunct sandbox? 

Also, try 'strace -p <emerge pid> -o TRACE' to look for clues about what the parent process is doing. 
Comment 2 yegle 2009-07-27 13:28:30 UTC
There is only sandbox whose parent is emerge as far as I can remember

I'm emerging gcc again, see if I can give you more hints.


(In reply to comment #1)
> Would you do 'ps axf' when it is hung, and show all child processes of your
> emerge -- there really ought to be more than just the defunct sandbox? 
> 
> Also, try 'strace -p <emerge pid> -o TRACE' to look for clues about what the
> parent process is doing. 
> 

Comment 3 yegle 2009-07-28 00:13:10 UTC
(In reply to comment #1)
> Would you do 'ps axf' when it is hung, and show all child processes of your
> emerge -- there really ought to be more than just the defunct sandbox? 
> 
> Also, try 'strace -p <emerge pid> -o TRACE' to look for clues about what the
> parent process is doing. 
> 

ps axf result:
 7873 ?        Sl     4:00 yakuake -session 1014cd7d2d4000124377837600000039660015_1248640792_778987
20977 pts/5    Ss     0:00  \_ /bin/bash
13750 pts/5    SN+    0:11  |   \_ /usr/bin/python /usr/bin/emerge gcc -1
14965 pts/5    ZN+    0:00  |       \_ [sandbox] <defunct>
11425 pts/6    Ss     0:00  \_ /bin/bash
11440 pts/6    R+     0:00      \_ ps axf

$ sudo strace -p 13750
Process 13750 attached - interrupt to quit
restart_syscall(<... resuming interrupted call ...>

Comment 4 Wormo (RETIRED) gentoo-dev 2009-07-28 06:34:12 UTC
Ok how about another test, as I try to figure out who should get assigned this interesting problem (portage, sandbox, toolchain devs)...

Run your emerge with --debug, save the output to a file, and attach here

Also, could you post output of 'qlop -l' to show what got upgraded before you got stuck on gcc emerge
Comment 5 yegle 2009-07-28 07:17:09 UTC
Created attachment 199416 [details]
qlop -l output

this is my qlop -l output~
Comment 6 yegle 2009-07-28 13:47:31 UTC
+ return 0
+ touch /home/yegle/temp/portage/sys-devel/gcc-4.4.1/.compiled
+ vecho '>>> Source compiled.'
+ quiet_mode
+ [[ '' -eq 1 ]]
+ echo '>>> Source compiled.'
>>> Source compiled.
+ ebuild_phase post_src_compile
+ declare -F post_src_compile
+ trap - SIGINT SIGQUIT
+ set +x
^C


the last lines of emerge --debug log

the complete log is too large, so I uploaded it here:http://yegle.net/emerge_debug_log


(In reply to comment #4)
> Ok how about another test, as I try to figure out who should get assigned this
> interesting problem (portage, sandbox, toolchain devs)...
> 
> Run your emerge with --debug, save the output to a file, and attach here
> 
> Also, could you post output of 'qlop -l' to show what got upgraded before you
> got stuck on gcc emerge
> 

Comment 7 Wormo (RETIRED) gentoo-dev 2009-07-28 21:30:01 UTC
Ok, it doesn't look like a problem launching sandbox -- compile phase finished, and install phase didn't start yet. Assigning to portage team.
Comment 8 Zac Medico gentoo-dev 2009-07-28 21:41:00 UTC
There must be some process forked from the ebuild running in the background. If  `ps axf` doesn't show it, maybe try pstree. You can also try running it with FEATURES=userpriv and search for processes running under the 'portage' user.
Comment 9 yegle 2009-07-29 04:17:54 UTC
(In reply to comment #8)
> There must be some process forked from the ebuild running in the background. If
>  `ps axf` doesn't show it, maybe try pstree. You can also try running it with
> FEATURES=userpriv and search for processes running under the 'portage' user.
> 

actually,there is no other process forked from ebuild...

I tried to emerge gcc with FEATURES=userpriv, seems the result is a little different

pstree:
     `-yakuake-+-bash---pstree
               |-bash---emerge---ebuild.sh
               `-{yakuake}

$ ps -ef|grep ^portage
portage   6626  5306  0 16:11 pts/1    00:00:00 [ebuild.sh] <defunct>
portage  13581     1  0 16:23 pts/1    00:00:00 /bin/sh

Comment 10 Zac Medico gentoo-dev 2009-07-29 06:51:17 UTC
(In reply to comment #9)
> $ ps -ef|grep ^portage
> portage   6626  5306  0 16:11 pts/1    00:00:00 [ebuild.sh] <defunct>
> portage  13581     1  0 16:23 pts/1    00:00:00 /bin/sh

It must come from the somewhere within the ebuild and/or gcc build system. I'm not aware of a clean/portable way for portage to clean up an orphaned process such as this. I suppose we could just clean up the ebuild.sh process and leave any orphans running in the background.

@toolchain: Has anyone else experienced a /bin/sh orphan like this?
Comment 11 Zac Medico gentoo-dev 2009-07-29 09:10:32 UTC
(In reply to comment #10)
> It must come from the somewhere within the ebuild and/or gcc build system. I'm
> not aware of a clean/portable way for portage to clean up an orphaned process
> such as this. I suppose we could just clean up the ebuild.sh process and leave
> any orphans running in the background.

I guess we can put ebuild.sh and all of it's subprocesses into a process group and that should make it easy to clean up any orphans.
Comment 12 Zac Medico gentoo-dev 2009-07-29 22:18:21 UTC
Creating a separate login session for ebuild.sh seems somewhat complex, so it might be better to first focus on implementing a fix that ignores orphan processes and simply leaves them running in the background (they might consume a pty device, but that's probably negligible).
Comment 13 Zac Medico gentoo-dev 2009-07-30 07:35:46 UTC
Created attachment 199617 [details, diff]
make ebuild.sh clean up orphaned processes

If this patch is saved as /tmp/cleanup_orphans.patch, then it can be applied as follows:

  cd /usr/lib/portage
  patch -p0 < /tmp/cleanup_orphans.patch
Comment 14 Zac Medico gentoo-dev 2009-08-03 20:17:42 UTC
For now, I've reverted this patch since we're going to need a daemon process in the ebuild's login session in order to pass signals from the controlling terminal to the detached session. A simple fifo-based approach in ebuild.sh does not seem to work since bash's read builtin occasionally loses the fifo data when it's 'Interrupted system call'. Maybe a python script will work better for the session leader/daemon. NOTE: The daemon will also be useful for implementing a fifo-based die helper (to replace the current signal-based approach).
Comment 15 Stefan Bauer 2010-06-09 13:20:02 UTC
Seems that this one is blocking also Bug #269283 (https://bugs.gentoo.org/show_bug.cgi?id=269283).
Comment 16 Zac Medico gentoo-dev 2010-08-13 14:56:03 UTC
This is fixed in git:

http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=9a5f9cf8f6a8ff78cc124c40aaebcedd7be8d059

It just leaves the process(es) running, but at least emerge doesn't hang now.
Comment 17 SpanKY gentoo-dev 2010-08-15 06:43:05 UTC
*** Bug 306265 has been marked as a duplicate of this bug. ***
Comment 18 Stefan Bauer 2010-08-18 20:54:18 UTC
(In reply to comment #16)
> This is fixed in git:
> 
> http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=9a5f9cf8f6a8ff78cc124c40aaebcedd7be8d059
> 
> It just leaves the process(es) running, but at least emerge doesn't hang now.

I just tested your fix and it works, but only if I _don't_ use MAKEOPTS="-j2".

Otherwise it just keeps hanging.
Comment 19 Zac Medico gentoo-dev 2010-08-18 21:14:06 UTC
(In reply to comment #18)
> I just tested your fix and it works, but only if I _don't_ use MAKEOPTS="-j2".
> 
> Otherwise it just keeps hanging.

Please make sure you have the latest version of portage from git since there were some bug fixes in the ipc code.

If you still have the problem, please check if `lsof | grep .ipc` show emerge is still listening on $PORTAGE_TMPDIR/portage/sys-devel/gcc-*/.ipc_in which would indicate that the ebuild is hung up.

If .ipc_in does not show in the lsof of output then it means that emerge itself is hung up. In this case it's possible to send a SIGUSR1 signal to the emerge process and see where it's hung up, like this:

kill -s SIGUSR1 <emerge pid>

That will bring you to the (Pdb) prompt, where you should issue these two commands:

step
bt

The bt command will display a backtrace that shows where emerge is hung up.
Comment 20 Zac Medico gentoo-dev 2010-08-23 06:01:21 UTC
This is in the 2.2_rc68, but I'll leave this bug open until it's in an unmasked version.
Comment 21 Zac Medico gentoo-dev 2010-09-04 08:14:15 UTC
This is fixed in 2.1.9.

Please file new a new bug if it's not working as expected.
Comment 22 Stefan Bauer 2010-09-04 16:52:14 UTC
(In reply to comment #21)
> This is fixed in 2.1.9.
> 
> Please file new a new bug if it's not working as expected.

I'm sorry, but here you are: bug 335950.

(In reply to comment #19)
> (In reply to comment #18)
> > I just tested your fix and it works, but only if I _don't_ use
> > MAKEOPTS="-j2".
> > 
> > Otherwise it just keeps hanging.
> 
> Please make sure you have the latest version of portage from git since there
> were some bug fixes in the ipc code.
> 
> If you still have the problem, please check if `lsof | grep .ipc` show emerge
> is still listening on $PORTAGE_TMPDIR/portage/sys-devel/gcc-*/.ipc_in which
> would indicate that the ebuild is hung up.
> 
> If .ipc_in does not show in the lsof of output then it means that emerge
> itself
> is hung up. In this case it's possible to send a SIGUSR1 signal to the emerge
> process and see where it's hung up, like this:
> 
> kill -s SIGUSR1 <emerge pid>
> 
> That will bring you to the (Pdb) prompt, where you should issue these two
> commands:
> 
> step
> bt
> 
> The bt command will display a backtrace that shows where emerge is hung up.

Thanks for this debugging hints. I added the output there:
bug 335950 comment 3
bug 335950 comment 4
Comment 23 Zac Medico gentoo-dev 2010-10-20 15:29:19 UTC
NOTE: The fix for this bug only works as long as USE=ipc is enabled (it is enabled automatically by IUSE default).