Unfortunately serve/servlet does not have a way to know when it's ready. However, serve does provide a confirmation-channel argument that sends back which port was opened, so you could listen to that. That's kind of a pain in the neck, because even though you have dispatch/servlet it's not very nice.
However, something I've done before for the same effect is to wait for the banner to be printed (it uses confirmation-channel so it knows what port to report in the banner). You can see this at: https://github.com/plt/racket/blob/master/collects/tests/web-server/pr/11125.rkt Another thing to do would be to start the server in one thread, then use another thread to poll the port until it gets a response, and then setuid in that thread. Jay On Fri, Sep 16, 2011 at 1:50 PM, Jeremy Kun <[email protected]> wrote: > Right so I just have to call set-uid once on the first start request, > because serve/servlet hangs. Is there a slicker way to have serve/servlet > call some given initialization function once after doing it's work and > before receiving any requests? I don't see anything for that in the > documentation, but maybe I missed it. Anyway, what I have works at least. > Exactly how unsafe is it? Is it just unportable? > And thanks, Eli, but I'm less scared of hard-coding my known ruid than > having a piece of data floating around with a pointer to my passwd. (even if > it's hashed) > > Jeremy > > > On Fri, Sep 16, 2011 at 1:26 PM, John Clements <[email protected]> > wrote: >> >> On Sep 16, 2011, at 11:03 AM, Jay McCarthy wrote: >> >> > I think you can use ffi-lib with #f because it is already attached. >> >> Yeah, okay, looks like this works: >> >> #lang racket >> >> (require ffi/unsafe) >> >> ;; return type is "gid_t". Safe to use int? >> (define setuid >> (get-ffi-obj "setuid" (ffi-lib #f) >> (_fun _int -> _int))) >> >> (setuid 0) >> >> >> ... naturally, the setuid 0 fails, you'd have to start as root and go >> down. Also, you'd need to do that *after* the listen on port 80. >> >> John >> > > -- Jay McCarthy <[email protected]> Assistant Professor / Brigham Young University http://faculty.cs.byu.edu/~jay "The glory of God is Intelligence" - D&C 93 _________________________________________________ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/users

