This is strange, when I test with simple data, for example:

(setq Lst '((4 5 6) (7 8 9)))
(println (eval> '+Agent 1 'setArticleWords (lit Lst)))

Then everything works just fine, the data is stored properly and I get
proper return values.

Then when I run the real code I just breaks down:

[import_feeds.l:7] !? (out Sock (pr (rest)))
5 -- Bad FD

If I then do for instance (pretty (rest)) there I get exactly the same
kind of list as in the simple test case, the only difference is that
it's much much longer. 5 is also the descriptor for the socket in both

My wrapper now looks like this:

(class +Agent)

(dm connect> (SockNum)
   (connect "localhost" (+ 4040 SockNum)))

(dm sock> (A)
   (let SockNum (if (num? A) A (max 1 (/ (; A aid) 10000)))
         (: sock)
         (=3D: sock
            (let Sock (connect> This SockNum)
               (if Sock
                  (call "sh" "-c"
                     (pack "./p projects/rss-reader/word_index.l -go "
SockNum " -wait >> index.log 2>&1 &"))
                  (connect> This SockNum)))))))

(dm eval> (A . @)
   (let? Sock (sock> This A)
      (out Sock (pr (rest)))
      (prog1 (in Sock (rd))
         (close Sock))))

I've also tested tracing everything in the word index server and it
looks good, the data arrives and gets inserted and so on. So the FD
error seems to appear only after the index server actually returns the

This I don't understand either as the error seems to imply that I'm
trying to open a socket that doesn't exist, which it does as it is
obviously receiving data and handling the data OK. The error only pops
up after the index server is done.

I hope I just missed something again here?

On Sun, Feb 7, 2010 at 9:39 PM, Henrik Sarvell <> wrote:
> Thanks for the help Alex, it works now, I use this line to start:
> (call "sh" "-c" "./p projects/rss-reader/word_index.l -go 1 -wait >>
> index.log 2>&1 &")
> Combined with this go function:
> (de go ()
> =A0 (setq *IdxNum (format (opt)))
> =A0 (setq *DbDir (pack "/opt/resources/index" *IdxNum "/"))
> =A0 (unless (info *DbDir)
> =A0 =A0 =A0(call 'mkdir *DbDir))
> =A0 (setq *DbDir (pack *DbDir "db/") )
> =A0 (unless (info *DbDir)
> =A0 =A0 =A0(call 'mkdir *DbDir))
> =A0 (pool (pack *DbDir "db"))
> =A0 (task (port (+ *IdxNum 4040))
> =A0 =A0 =A0(let? Sock (accept @)
> =A0 =A0 =A0 =A0 (unless (fork)
> =A0 =A0 =A0 =A0 =A0 =A0(in Sock
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 (while (rd)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(sync)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(out Sock
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (pr (eval @)))))
> =A0 =A0 =A0 =A0 =A0 =A0(bye))
> =A0 =A0 =A0 =A0 (close Sock)))
> =A0 (forked))
> Something that compounded the confusion earlier was the fact that I
> was calling (go) at the end of word_index.l; probably a result of
> trial and error testing in response to the behavior you describe
> above. So when copying lines back and forth I was suddenly calling go
> twice, or perhaps not at all sometimes.
> On Sun, Feb 7, 2010 at 5:38 PM, Alexander Burger <> wr=
>> On Sun, Feb 07, 2010 at 05:22:08PM +0100, Alexander Burger wrote:
>>> How does "word_index.l" handle the arguments following the single '-'?
>>> =A0 =A0.../word_index.l - 1 -go -wait ...
>>> A single dash inhibits the evaluation of further arguments, so
>> I would suggest that you call it as
>>> =A0 =A0.../word_index.l -go 1 -wait ...
>> and have 'go' call (format (opt)) to retrieve the number '1'. 'opt' will
>> skip this argument, so that when 'go' is done, 'wait' will be executed
>> as desired.
>> Cheers,
>> - Alex
>> --

Reply via email to