2016-08-14T00:14:30Z DeadTrickster quit (Ping timeout: 244 seconds) 2016-08-14T00:50:37Z oleo_ joined #sbcl 2016-08-14T00:54:07Z oleo quit (Ping timeout: 244 seconds) 2016-08-14T01:17:35Z em1l joined #sbcl 2016-08-14T01:20:40Z em1l_ quit (Ping timeout: 252 seconds) 2016-08-14T01:29:04Z karswell` is now known as karswell 2016-08-14T02:06:32Z fe[nl]ix quit (Remote host closed the connection) 2016-08-14T02:06:32Z Blkt quit (Read error: Connection reset by peer) 2016-08-14T02:06:45Z Blkt joined #sbcl 2016-08-14T02:06:47Z fe[nl]ix joined #sbcl 2016-08-14T02:36:04Z stassats quit (Ping timeout: 244 seconds) 2016-08-14T02:48:07Z nyef joined #sbcl 2016-08-14T04:04:42Z karswell` joined #sbcl 2016-08-14T04:04:53Z karswell quit (Remote host closed the connection) 2016-08-14T04:35:33Z nyef quit (Ping timeout: 240 seconds) 2016-08-14T05:05:47Z milanj quit (Quit: This computer has gone to sleep) 2016-08-14T06:18:13Z gingerale joined #sbcl 2016-08-14T06:32:13Z DeadTrickster joined #sbcl 2016-08-14T07:13:54Z oleo_ quit (Quit: Leaving) 2016-08-14T07:20:42Z oleo joined #sbcl 2016-08-14T07:39:18Z angavrilov joined #sbcl 2016-08-14T07:41:13Z SamSkulls quit (Remote host closed the connection) 2016-08-14T07:49:18Z shka_ joined #sbcl 2016-08-14T08:36:24Z Bike quit (Quit: leaving) 2016-08-14T09:05:39Z ASau quit (Ping timeout: 250 seconds) 2016-08-14T09:21:14Z DeadTrickster quit (Read error: Connection reset by peer) 2016-08-14T09:23:35Z ASau joined #sbcl 2016-08-14T09:25:57Z DeadTrickster joined #sbcl 2016-08-14T09:53:05Z milanj joined #sbcl 2016-08-14T10:39:30Z sjl quit (Ping timeout: 244 seconds) 2016-08-14T11:12:27Z attila_lendvai joined #sbcl 2016-08-14T11:16:12Z stassats joined #sbcl 2016-08-14T12:04:44Z attila_lendvai quit (Ping timeout: 260 seconds) 2016-08-14T12:08:41Z pipping: Hi. 2016-08-14T12:09:39Z pipping: I'd like to ask a question about spawning of external processes in sbcl. 2016-08-14T12:12:09Z pipping: Say I spawn an external process, asynchronously, using sb-ext:run-program with :wait nil. I'd then like to kill the process at some point. To my knowledge, I can only do this with sbcl by calling kill on unix (be it through `process-kill` or by shelling out) or by running "taskkill" on windows. 2016-08-14T12:14:41Z pipping: But I cannot be sure if the process is still alive. I could check using `process-alive-p` but not without a race condition. 2016-08-14T12:15:00Z stassats quit (Ping timeout: 265 seconds) 2016-08-14T12:17:03Z pipping: If the process is already dead and I kill by PID (which I'd have to do on windows anyway and which process-kill appears to do on unix as well), unless the process stays around as a zombie after it died, I might try to kill a process that no longer exists or (in very rare but not impossible cases) even new processes because the PID has been recycled. 2016-08-14T12:18:49Z pipping: It appears that SBCL does not by default keep a zombie process around. I assume that the process is just garbage-collected (things are probably different if streams and `process-close` are involved but let's not focus on that for now). 2016-08-14T12:19:45Z stassats joined #sbcl 2016-08-14T12:23:07Z pipping: So my question(s), finally would be: Are the above observations correct? Does that mean that I cannot kill a process launched via `sb-ext:run-program` without a race condition or can I make sure this child process is not waited for (which would get rid of the zombie) somehow until I say it's okay? 2016-08-14T12:26:05Z stassats: what makes you think there is a race condition? 2016-08-14T12:41:43Z milanj quit (Quit: This computer has gone to sleep) 2016-08-14T12:42:13Z attila_lendvai joined #sbcl 2016-08-14T12:42:13Z attila_lendvai quit (Changing host) 2016-08-14T12:42:13Z attila_lendvai joined #sbcl 2016-08-14T12:45:11Z pipping: stassats: I mentioned multiple. There would be one if I wrote code if the form (unless (process-alive-p p) (process-kill p)), right? 2016-08-14T12:45:25Z pipping: s/unless/when/ 2016-08-14T12:46:56Z stassats: well, naturally, but that's just a property of kill() 2016-08-14T12:47:38Z pipping: yes, if I use it for processes that I have zero control over. 2016-08-14T12:48:30Z pipping: but if I spawn a process through sb-ext, I would assume (I haven't actually looked at the code, I apologise) that that's a fork+exec so that the process ends up being a child of sbcl. 2016-08-14T12:48:41Z pipping: sb-ext:run-program, I mean 2016-08-14T12:48:56Z stassats: sure, it's fork+exec (what else) 2016-08-14T12:49:25Z pipping: and for children, I know that until I wait for them, they stick around as zombies. 2016-08-14T12:49:54Z stassats: sbcl catches sigchld 2016-08-14T12:51:24Z pipping: okay. does it them immediately call wait()? otherwise it'll still be a zombie, no? 2016-08-14T12:52:02Z stassats: yes, the sigchld handler calls waitpid 2016-08-14T12:55:56Z stassats: i think there is a way to solve that 2016-08-14T12:56:27Z pipping: Okay. And with that, the child is gone, and the OS is free to reuse the PID. So the following may happen in this order: (1) I get the PID from the child, (2) the child terminates and sends SIGCHLD, (3) sbcl handles it and calls wait (4) the OS creates another process by the same PID (5) I finally get to call kill yet kill the wrong process, no? 2016-08-14T12:57:10Z pipping: the unlikely but not impossible part being (4) since the OS will typically try to hand out other PIDs first 2016-08-14T12:57:32Z stassats: the sigchld handler grabs with-active-processes-lock 2016-08-14T12:57:52Z stassats: if process-kill grabs it too, then they won't race 2016-08-14T13:01:15Z pipping: at a first glance, it does not look like it does. 2016-08-14T13:04:07Z DeadTrickster quit (Ping timeout: 252 seconds) 2016-08-14T13:04:49Z stassats quit (Ping timeout: 260 seconds) 2016-08-14T13:05:03Z stassats joined #sbcl 2016-08-14T13:05:58Z stassats: just need to figure out what to do with process groups 2016-08-14T13:23:46Z stassats: looks like the lock wouldn't help process-kill with :PTY-PROCESS-GROUP 2016-08-14T13:26:13Z DeadTrickster joined #sbcl 2016-08-14T13:32:45Z stassats: i can't figure out how to properly launch "top"... 2016-08-14T14:17:44Z attila_lendvai quit (Ping timeout: 260 seconds) 2016-08-14T14:37:35Z nyef joined #sbcl 2016-08-14T14:39:44Z karswell` is now known as karswell 2016-08-14T14:47:14Z yang_ quit (Ping timeout: 264 seconds) 2016-08-14T14:52:21Z blackwolf joined #sbcl 2016-08-14T14:58:01Z attila_lendvai joined #sbcl 2016-08-14T14:58:01Z attila_lendvai quit (Changing host) 2016-08-14T14:58:01Z attila_lendvai joined #sbcl 2016-08-14T15:43:27Z stassats quit (Ping timeout: 250 seconds) 2016-08-14T15:46:42Z angavrilov_ joined #sbcl 2016-08-14T15:51:21Z angavrilov quit (Ping timeout: 276 seconds) 2016-08-14T16:06:35Z Bike joined #sbcl 2016-08-14T16:18:32Z DeadTrickster quit (Ping timeout: 240 seconds) 2016-08-14T16:19:39Z attila_lendvai quit (Ping timeout: 260 seconds) 2016-08-14T16:20:55Z gargaml joined #sbcl 2016-08-14T16:27:17Z gargaml quit (Quit: WeeChat 1.5) 2016-08-14T16:44:33Z gargaml joined #sbcl 2016-08-14T17:06:47Z gargaml quit (Quit: WeeChat 1.5) 2016-08-14T18:00:17Z iskander joined #sbcl 2016-08-14T18:00:41Z angavrilov_ is now known as angavrilov 2016-08-14T18:40:21Z sjl joined #sbcl 2016-08-14T18:57:15Z milanj joined #sbcl 2016-08-14T19:08:46Z sigjuice quit (Ping timeout: 252 seconds) 2016-08-14T19:11:36Z sigjuice joined #sbcl 2016-08-14T19:29:22Z gingerale quit (Remote host closed the connection) 2016-08-14T19:30:56Z pipping: The docstring for sb-ext:process-close is rather confusing btw: "Close all streams connected to process and stop maintaining the status slot." There are streams which the process owns (the ones requested by passing :stream to :input/:output/:error) and those that it doesn't (which you pass as :input/:output/:error). process-close only closes the former, not the latter, even though I'd say they're still connected to the process. 2016-08-14T19:31:23Z pipping: s/still/both/ 2016-08-14T19:36:26Z pipping: it's also not quite clear what maintaining the status slot means. I would call process-close after waiting for a process to terminate. If I then inquired about the process-status it'd be :exited and that could never change. But maybe I could also call process-close to close a stream while the process is still running? So what would not continue to be maintained? Would the status no longer be kept up-to-date? Or would process-status even quit retur 2016-08-14T19:36:32Z pipping: ... the exit status at some point? 2016-08-14T19:38:51Z iskander quit (Ping timeout: 276 seconds) 2016-08-14T19:39:17Z stassats joined #sbcl 2016-08-14T19:43:51Z iskander joined #sbcl 2016-08-14T19:51:43Z SamSkulls joined #sbcl 2016-08-14T20:13:34Z attila_lendvai joined #sbcl 2016-08-14T20:13:34Z attila_lendvai quit (Changing host) 2016-08-14T20:13:34Z attila_lendvai joined #sbcl 2016-08-14T20:45:01Z shka_ quit (Ping timeout: 252 seconds) 2016-08-14T21:11:58Z DeadTrickster joined #sbcl 2016-08-14T21:11:59Z pipping: stassats: so to reiterate (to make sure I understood correctly), yes, there is currently a race between the SIGCHLD signal handler and process-kill and it could be solved for the case of killing a single PID by acquiring the lock for *active-processes* in process-kill but the :pty-process-group will need a more involved fix? 2016-08-14T21:17:13Z stassats quit (Ping timeout: 244 seconds) 2016-08-14T21:22:19Z stassats joined #sbcl 2016-08-14T22:15:37Z DeadTrickster quit (Read error: Connection reset by peer) 2016-08-14T22:26:35Z nyef quit (Ping timeout: 258 seconds) 2016-08-14T22:28:54Z angavrilov quit (Remote host closed the connection) 2016-08-14T22:29:37Z DavidGu joined #sbcl 2016-08-14T22:41:04Z DavidGu quit (Quit: DavidGu) 2016-08-14T22:41:24Z DavidGu joined #sbcl 2016-08-14T22:46:01Z DavidGu quit (Ping timeout: 252 seconds) 2016-08-14T23:34:49Z attila_lendvai quit (Ping timeout: 260 seconds) 2016-08-14T23:51:11Z p_l quit (Ping timeout: 244 seconds) 2016-08-14T23:51:58Z p_l joined #sbcl