Skip to content

Commit

Permalink
sevlyar#100: child isn't able to get fds before they're closed
Browse files Browse the repository at this point in the history
  • Loading branch information
NorseGaud committed Apr 8, 2024
1 parent cf7c234 commit ceddf9b
Show file tree
Hide file tree
Showing 2 changed files with 313 additions and 0 deletions.
2 changes: 2 additions & 0 deletions daemon_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"path/filepath"
"syscall"
"time"
)

// A Context describes daemon context.
Expand Down Expand Up @@ -165,6 +166,7 @@ func (d *Context) openFiles() (err error) {
}

func (d *Context) closeFiles() (err error) {
time.Sleep(1 * time.Second) // allow children to get the proper FDs before they're closed: https://github.com/sevlyar/go-daemon/issues/100
cl := func(file **os.File) {
if *file != nil {
(*file).Close()
Expand Down
311 changes: 311 additions & 0 deletions sample.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,311 @@
2024/04/05 15:12:52 - - - - - - - - - - - - - - -
2024/04/05 15:12:52 daemon started
2024/04/05 15:12:53 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
2024/04/05 15:34:33 - - - - - - - - - - - - - - -
2024/04/05 15:34:33 daemon started
2024/04/05 15:34:34 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
2024/04/05 15:36:50 - - - - - - - - - - - - - - -
2024/04/05 15:36:50 daemon started
2024/04/05 15:36:51 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
2024/04/05 15:36:54 terminating...
2024/04/05 15:39:32 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
2024/04/05 15:40:23 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
2024/04/05 15:43:56 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
2024/04/05 15:47:52 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
2024/04/05 16:54:16 error making GET request to google.com err Get "https://google.com": dial tcp 172.217.3.78:443: connect: bad file descriptor
2024/04/05 16:57:35 error making GET request to google.com err Get "https://google.com": dial tcp 172.217.3.78:443: connect: bad file descriptor
2024/04/05 17:02:48 error making GET request to google.com err Get "https://google.com": dial tcp 142.250.217.238:443: connect: bad file descriptor
2024/04/05 17:03:50 error making GET request to google.com err Get "https://google.com": dial tcp 142.250.217.238:443: connect: bad file descriptor
2024/04/05 17:07:44 error making GET request to google.com err Get "https://google.com": dial tcp 142.250.217.238:443: connect: bad file descriptor
2024/04/05 17:11:35 error making GET request to google.com err Get "https://google.com": dial tcp 142.250.217.238:443: connect: bad file descriptor
2024/04/05 17:12:36 error making GET request to google.com err Get "https://google.com": dial tcp 142.250.217.174:443: connect: bad file descriptor
2024/04/05 17:13:10 error making GET request to google.com err Get "https://google.com": dial tcp 142.250.217.174:443: connect: bad file descriptor
2024/04/05 17:13:39 error making GET request to google.com err Get "https://google.com": dial tcp 142.250.217.174:443: connect: bad file descriptor
2024/04/05 17:21:30 - - - - - - - - - - - - - - -
2024/04/05 17:21:30 daemon started
2024/04/05 17:21:48 terminating...
2024/04/05 17:22:01 error making GET request to google.com err Get "https://google.com": dial tcp: lookup google.com: i/o timeout
2024/04/05 17:27:29 - - - - - - - - - - - - - - -
2024/04/05 17:27:29 daemon started
2024/04/05 17:27:49 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
2024/04/05 17:28:50 terminating...
2024/04/05 17:30:04 - - - - - - - - - - - - - - -
2024/04/05 17:30:04 daemon started
2024/04/05 17:30:05 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
2024/04/05 17:30:09 terminating...
2024/04/05 17:32:15 - - - - - - - - - - - - - - -
2024/04/05 17:32:15 daemon started
2024/04/05 17:32:16 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
2024/04/05 17:32:26 terminating...
2024/04/05 17:34:36 - - - - - - - - - - - - - - -
2024/04/05 17:34:36 daemon started
1
2024/04/05 17:34:37 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/05 17:34:38 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/05 17:34:39 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/05 17:34:40 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/05 17:34:41 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/05 17:34:42 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/05 17:34:43 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/05 17:34:44 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/05 17:34:45 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/05 17:34:46 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/05 17:34:47 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
2024/04/05 17:34:48 terminating...
2024/04/05 17:34:48 daemon terminated
2024/04/05 17:38:23 - - - - - - - - - - - - - - -
2024/04/05 17:38:23 daemon started
1
2024/04/05 17:38:24 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/05 17:38:25 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/05 17:38:26 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/05 17:38:27 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/05 17:38:28 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
2024/04/05 17:38:29 terminating...
2024/04/05 17:38:29 daemon terminated
2024/04/05 17:40:18 - - - - - - - - - - - - - - -
2024/04/05 17:40:18 daemon started
1
2024/04/05 17:40:19 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/05 17:40:20 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/05 17:40:21 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/05 17:40:22 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/05 17:40:23 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/05 17:40:24 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/05 17:40:25 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
2024/04/05 17:40:25 terminating...
2024/04/05 17:40:26 daemon terminated
2024/04/05 17:40:33 - - - - - - - - - - - - - - -
2024/04/05 17:40:33 daemon started
1
2024/04/05 17:40:34 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/05 17:40:35 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/05 17:40:36 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
2024/04/05 17:40:36 terminating...
2024/04/05 17:40:37 daemon terminated
2024/04/05 17:41:37 - - - - - - - - - - - - - - -
2024/04/05 17:41:37 daemon started
1
2024/04/05 17:41:38 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/05 17:41:39 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/05 17:41:40 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/05 17:41:41 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/05 17:41:42 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
2024/04/05 17:41:42 terminating...
2024/04/05 17:41:43 daemon terminated
2024/04/05 17:45:33 - - - - - - - - - - - - - - -
2024/04/05 17:45:33 daemon started
1
2024/04/05 17:45:34 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/05 17:45:35 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/05 17:45:36 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/05 17:45:37 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
2024/04/05 17:45:37 terminating...
2024/04/05 17:45:38 daemon terminated
2024/04/07 09:08:03 - - - - - - - - - - - - - - -
2024/04/07 09:08:03 daemon started
1
2024/04/07 09:08:04 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/07 09:08:05 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/07 09:08:06 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/07 09:08:07 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/07 09:08:08 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
2024/04/07 09:08:08 terminating...
2024/04/07 09:08:09 daemon terminated
2024/04/07 09:11:02 - - - - - - - - - - - - - - -
2024/04/07 09:11:02 daemon started
1
2024/04/07 09:11:03 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/07 09:11:04 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/07 09:11:05 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/07 09:11:06 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
1
2024/04/07 09:11:07 error making GET request to google.com err Get "https://google.com": tls: failed to verify certificate: SecPolicyCreateSSL error: 0
2024/04/07 09:11:08 terminating...
2024/04/07 09:11:08 daemon terminated
2024/04/07 09:19:24 - - - - - - - - - - - - - - -
2024/04/07 09:19:24 daemon started
1
2024/04/07 09:19:30 error making GET request to google.com err Get "https://google.com": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
1
2024/04/07 09:19:36 error making GET request to google.com err Get "https://google.com": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
1
2024/04/07 09:19:39 terminating...
2024/04/07 09:19:42 error making GET request to google.com err Get "https://google.com": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
2024/04/07 09:19:43 daemon terminated
2024/04/07 09:24:48 - - - - - - - - - - - - - - -
2024/04/07 09:24:48 daemon started
2024/04/07 09:24:54 error making GET request to google.com err Get "https://google.com": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
2024/04/07 09:24:57 terminating...
2024/04/07 09:25:00 error making GET request to google.com err Get "https://google.com": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
2024/04/07 09:25:01 daemon terminated
2024/04/07 09:25:19 - - - - - - - - - - - - - - -
2024/04/07 09:25:19 daemon started
2024/04/07 09:25:24 error making GET request to google.com err Get "https://google.com": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
2024/04/07 09:26:08 - - - - - - - - - - - - - - -
2024/04/07 09:26:08 daemon started
2024/04/07 09:26:13 error making GET request to google.com err Get "https://google.com": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
2024/04/07 09:28:14 error making GET request to google.com err Get "https://google.com": dial tcp 142.250.64.206:443: connect: bad file descriptor
2024/04/07 09:30:20 error making GET request to google.com err Get "https://google.com": dial tcp 142.250.64.206:443: connect: bad file descriptor
2024/04/07 09:31:20 - - - - - - - - - - - - - - -
2024/04/07 09:31:20 daemon started
2024/04/07 09:31:25 error making GET request to google.com err Get "https://google.com": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
2024/04/07 09:32:43 - - - - - - - - - - - - - - -
2024/04/07 09:32:43 daemon started
in worker
2024/04/07 09:32:49 error making GET request to google.com err Get "https://google.com": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
in worker
2024/04/07 09:32:50 terminating...
2024/04/07 09:32:55 error making GET request to google.com err Get "https://google.com": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
in worker
2024/04/07 09:32:56 daemon terminated
2024/04/07 09:36:04 - - - - - - - - - - - - - - -
2024/04/07 09:36:04 daemon started
2024/04/07 09:36:09 error making GET request to google.com err Get "https://google.com": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
2024/04/07 09:36:41 - - - - - - - - - - - - - - -
2024/04/07 09:36:41 daemon started
2024/04/07 09:36:46 error making GET request to google.com err Get "http://google.com": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
2024/04/07 09:37:14 - - - - - - - - - - - - - - -
2024/04/07 09:37:14 daemon started
2024/04/07 09:37:14 error making GET request to google.com err Get "http://1.1.1.1": dial tcp 1.1.1.1:80: connect: bad file descriptor
2024/04/08 10:14:10 - - - - - - - - - - - - - - -
2024/04/08 10:14:10 daemon started
GET request status: 200 OK
in worker
in worker
in worker
in worker
in worker
2024/04/08 10:14:14 terminating...
2024/04/08 10:14:15 daemon terminated
2024/04/08 10:15:40 - - - - - - - - - - - - - - -
2024/04/08 10:15:40 daemon started
2024/04/08 10:15:40 error making GET request err Get "http://1.1.1.1": dial tcp 1.1.1.1:80: connect: bad file descriptor
2024/04/08 10:15:48 - - - - - - - - - - - - - - -
2024/04/08 10:15:48 daemon started
2024/04/08 10:15:48 error making GET request err Get "http://1.1.1.1": dial tcp 1.1.1.1:80: connect: bad file descriptor
2024/04/08 10:16:17 - - - - - - - - - - - - - - -
2024/04/08 10:16:17 daemon started
2024/04/08 10:16:17 error making MAIN GET request err Get "http://1.1.1.1": dial tcp 1.1.1.1:80: connect: bad file descriptor
2024/04/08 10:19:07 - - - - - - - - - - - - - - -
2024/04/08 10:19:07 daemon started
2024/04/08 10:19:07 error making MAIN GET request err Get "http://1.1.1.1": dial tcp 1.1.1.1:80: connect: bad file descriptor
2024/04/08 10:22:52 - - - - - - - - - - - - - - -
2024/04/08 10:22:52 daemon started
2024/04/08 10:22:52 error making MAIN GET request err Get "http://1.1.1.1": dial tcp 1.1.1.1:80: connect: bad file descriptor
2024/04/08 10:23:29 - - - - - - - - - - - - - - -
2024/04/08 10:23:29 daemon started
2024/04/08 10:23:29 error making MAIN GET request err Get "http://1.1.1.1": dial tcp 1.1.1.1:80: connect: bad file descriptor
2024/04/08 10:23:42 - - - - - - - - - - - - - - -
2024/04/08 10:23:42 daemon started
2024/04/08 10:23:42 error making MAIN GET request err Get "http://1.1.1.1": dial tcp 1.1.1.1:80: connect: bad file descriptor
2024/04/08 10:24:43 - - - - - - - - - - - - - - -
2024/04/08 10:24:43 daemon started
2024/04/08 10:24:43 error making MAIN GET request err Get "http://1.1.1.1": dial tcp 1.1.1.1:80: connect: bad file descriptor
2024/04/08 10:48:28 - - - - - - - - - - - - - - -
2024/04/08 10:48:28 daemon started
2024/04/08 10:48:28 error making MAIN GET request err Get "http://1.1.1.1": dial tcp 1.1.1.1:80: connect: bad file descriptor
2024/04/08 10:48:36 - - - - - - - - - - - - - - -
2024/04/08 10:48:36 daemon started
2024/04/08 10:48:36 error making MAIN GET request err Get "http://1.1.1.1": dial tcp 1.1.1.1:80: connect: bad file descriptor
2024/04/08 10:49:55 - - - - - - - - - - - - - - -
2024/04/08 10:49:55 daemon started
2024/04/08 10:49:55 error making MAIN GET request err Get "http://1.1.1.1": dial tcp 1.1.1.1:80: connect: bad file descriptor
2024/04/08 10:50:11 - - - - - - - - - - - - - - -
2024/04/08 10:50:11 daemon started
2024/04/08 10:50:11 error making MAIN GET request err Get "http://1.1.1.1": dial tcp 1.1.1.1:80: connect: bad file descriptor
2024/04/08 10:51:18 - - - - - - - - - - - - - - -
2024/04/08 10:51:18 daemon started
MAIN GET request status: 200 OK
in worker
in worker
in worker
in worker
in worker
in worker
in worker
in worker
in worker
in worker
in worker
in worker
in worker
in worker
in worker
in worker
in worker
2024/04/08 10:51:34 terminating...
2024/04/08 10:51:35 daemon terminated
2024/04/08 10:53:39 - - - - - - - - - - - - - - -
2024/04/08 10:53:39 daemon started
2024/04/08 10:53:39 error making MAIN GET request err Get "http://1.1.1.1": dial tcp 1.1.1.1:80: connect: bad file descriptor
2024/04/08 10:55:34 - - - - - - - - - - - - - - -
2024/04/08 10:55:34 daemon started
MAIN GET request status: 200 OK
in worker
in worker
in worker
in worker
in worker
in worker
2024/04/08 10:55:40 terminating...
2024/04/08 10:55:41 daemon terminated
2024/04/08 10:58:13 - - - - - - - - - - - - - - -
2024/04/08 10:58:13 daemon started
MAIN GET request status: 200 OK
in worker
in worker
in worker
in worker
2024/04/08 10:58:17 terminating...
2024/04/08 10:58:17 daemon terminated
2024/04/08 10:58:27 - - - - - - - - - - - - - - -
2024/04/08 10:58:27 daemon started
MAIN GET request status: 200 OK
in worker
WORKER GET request to https://google.com status: 200 OK
in worker
WORKER GET request to https://google.com status: 200 OK
in worker
WORKER GET request to https://google.com status: 200 OK
in worker
2024/04/08 10:58:33 terminating...
WORKER GET request to https://google.com status: 200 OK
in worker
2024/04/08 10:58:34 daemon terminated

0 comments on commit ceddf9b

Please sign in to comment.