Re: [go-nuts] Limiting File Descriptors on Forked Linux cmd.exec

2024-03-04 Thread Jeff Stein
= 0 { goto childerror } continue } On Monday, March 4, 2024 at 1:13:08 PM UTC-7 Jeff Stein wrote: > It appears this was in fact the issue. > > I added some code to print out the `FD_CLOEXEC` state. Files called via > *syscall.Dupe2* end up with a *FD_CLOEXEC=0* whereas anything passed via

Re: [go-nuts] Limiting File Descriptors on Forked Linux cmd.exec

2024-03-04 Thread Jeff Stein
towards a wonderful discovery about what NOT to do :) On Monday, March 4, 2024 at 12:03:16 PM UTC-7 Jeff Stein wrote: > I think I may have discovered the issue. > > I made a sys call to duplicate the file descriptor > > dupFd, err := syscall.Dup(int(file.Fd())) > if err != nil { >

Re: [go-nuts] Limiting File Descriptors on Forked Linux cmd.exec

2024-03-04 Thread Jeff Stein
quals fd2, then dup2 returns fd2 without closing it. Otherwise, the FD_CLOEXEC file descriptor flag is cleared for fd2, so that fd2 is left open if the process calls exec.* Does this sound like what may have been happening? On Monday, March 4, 2024 at 9:04:31 AM UTC-7 Jeff Stein wrote: > OP h

Re: [go-nuts] Limiting File Descriptors on Forked Linux cmd.exec

2024-03-04 Thread Jeff Stein
comes around. > > Good point, I am assuming that the OP is using the os/exec package to > start up a new copy of the process. > > A simple fork without an exec can't work in Go, or in any > multi-threaded program. > > Ian > > > > > On Mar 1, 20

[go-nuts] Limiting File Descriptors on Forked Linux cmd.exec

2024-03-01 Thread Jeff Stein
I'm struggling to understand if I'm able to do something. In my very odd use case we are writing a websever that handles connections via a forked process. I have a listener process that listens for TCP connections. So each net.Conn that comes in we pull off its file descriptor: *fd, err := co