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

Re: Could anyone please explain this to me?

> I have a binary /foo that essantially does this:
> cd /
> fork;
> if father exit;
> setsid; 
> kill all processes not in own session
> umount /home
> This works fine, when I simply log in and start /foo as root. However,
> when I first cd /home after logging in and then start /foo it cannot
> unmount /home. As you might expect by now, I have to partitions: / and
> /home. That means I cannot umount /home if I started the binary with cwd
> on this partition although the child process doesn't even know about the
> original cwd. And my login shell ahs already been killed.
> What can I do to avoid this? For my example it's not that big an issue,
> but imagine /usr being mounted...

Sue me for being clueless, but:
  could it be that when you start the programm, you have the
  current director "open" in some way (like processes can have files open).
  then, the fork-ed child inherets all open fd's from the parent, and thus
  also has /home open.

Maybe (again, just guessing) something like this would help?
  if (current dir != "/"){
    cd /
  kill all processes not in own session
  unmount /home

(I'm hoping execv doesn't inherit open filediscriptors. The man page
doesn't mention anything about this, the execve manpage sais that
execve does inherit stuff).

> Thanks in advance
Well, actuall I don't think this all works, but hey, it could, cound't it?

joost witteveen, joostje@debian.org
#!/usr/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
#what's this? see http://www.dcs.ex.ac.uk/~aba/rsa/

TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-devel-request@lists.debian.org . 
Trouble?  e-mail to templin@bucknell.edu .

Reply to: