freenx-team team mailing list archive
-
freenx-team team
-
Mailing list archive
-
Message #00265
Re: Samba shares working?
Hi Jeremy,
On Monday 27 April 2009, Jeremy Wilkins wrote:
> I'm confused as to what this trap and loop accomplish. We can't paste code
> in until we understand the ramifications of the changes.
> > After some more debugging and testing I finally solved the problem. When
> > cmd_node_smbmount (as well as cmd_node_addprinter) is called, the
> > function gets instantly terminated (at least in my setup/environment)
> > because it was not properly detached.
> >
> > I had to add several things to the cmd_node_smbmount call:
> > - Use "double fork" (thanks to [1])
> > - Use trap
> > - Close all open file handles
I try to explain it a bit more detailed:
- The "double fork" is used to make sure the process outlives the current
shell. I thought this was necessary to detatch the process, but after
running another test, it works without the extra parentheses as well.
Updated patch attached.
- The trap command is used to catch signal 1 (SIGHUP), otherwise the process
terminates.
- The loop is used to close all open file handles. freenx uses some exec calls
like "exec 4>&1" but closes only STDIN, STDOUT and STDERR ( "exec 0<&-",
"exec 1>&-", "exec 2>&-" ). Maybe it's too much to close all open file
handles up to 255 (probably only a few are used), but it doesn't harm
either. Anyway, if you don't close these file handles, the process hangs.
Thilo
--
Thilo Uttendorfer
Linux Information Systems AG
Putzbrunner Str. 71, 81739 München
t.uttendorfer@xxxxxxxxxxxx, http://www.linux-ag.com
--- nxnode.orig 2009-04-09 16:00:02.000000000 +0200
+++ nxnode 2009-04-28 18:37:43.000000000 +0200
@@ -1560,10 +1560,10 @@
cmd_node_suspend
;;
--smbmount)
- cmd_node_smbmount &>/dev/null </dev/null &
+ trap '' 1; for ((i=3; i<255; i++)); do eval "exec $i<&- $i>&-"; done; cmd_node_smbmount &>/dev/null </dev/null &
;;
--addprinter)
- cmd_node_addprinter &>/dev/null </dev/null &
+ trap '' 1; for ((i=3; i<255; i++)); do eval "exec $i<&- $i>&-"; done; cmd_node_addprinter &>/dev/null </dev/null &
;;
--check)
echo "NX> 716 finished"
Follow ups