<Sargun>
I see in process_monitor.pony: // prepare argp and envp ahead of fork() as it's not safe
<Sargun>
// to allocate in the child after fork() was called.
<Sargun>
Why is that the case?
dlowe_ has joined #ponylang
Licenser_ has joined #ponylang
so has quit [*.net *.split]
dlowe has quit [*.net *.split]
Licenser has quit [*.net *.split]
dlowe_ is now known as dlowe
Licenser_ is now known as Licenser
so has joined #ponylang
so has quit [Ping timeout: 260 seconds]
so has joined #ponylang
infinitary has quit [Read error: Connection reset by peer]
khan has joined #ponylang
khan has quit [Quit: khan]
khan has joined #ponylang
acarrico has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
<SeanTAllen>
Sargun: there's no support for doing what that rust method does. There's a signals package that allows you to set/unset signals but nothing specific to "after a child is forked"
infinitary has joined #ponylang
infinitary has quit [Client Quit]
infinitary has joined #ponylang
jmiven has quit [Quit: co'o]
jmiven has joined #ponylang
_andre has joined #ponylang
khan has quit [Quit: khan]
khan has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
<Sargun>
SeanTAllen: Where does the restriction about not being allowed to do memory allocations come from?
<SeanTAllen>
sorry i dont understand what you mean
<SeanTAllen>
process notify takes stderr and stdout
<Sargun>
SeanTAllen: Rather than ProcessMonitor / ProcessNotify intercepting all of stdio, I'd like to just pass through the program's stdio
<Sargun>
so, my "subprogram" can write directly to stderr, and stdout
<SeanTAllen>
ProcessNotify doesnt have any hooks for stdio
<SeanTAllen>
what does "write directly to stderr" mean?
<aturley>
Sargun you'd have to build that yourself.
<Sargun>
SeanTAllen: Rather than pass a pipe to the forked program, pass the parent process's fd 0 / 1 / 2
<SeanTAllen>
I guess aturley understands, which is good, i'm missing something
<Sargun>
aturley: What's the "right" way to do this in pony?
<Sargun>
aturley: So, I did this just by copying the process codebase into my project, adn ripping out all of that code
<Sargun>
aturley: If I were to write this code with an implementation of ProcessNotify that didn't intercept stdio, what would be the "pony" way of doing this? Have a new BasicProcessNotify interface, and a separate constructor?
<SeanTAllen>
Sargun: do you want to exec another process and be done with it?
<Sargun>
SeanTAllen: I want to get the same semantic I have with fork / exec
<SeanTAllen>
that isnt what the process monitor is designed for
<Sargun>
Oh?
<SeanTAllen>
its designed to start up other processes and work with them
<SeanTAllen>
communicating over stdin/stdout
<jemc>
if you just want to [fork, exec], I think you could do so with a lot less code than ProcessMonitor uses
<jemc>
so, starting from scratch may be a better option than copying and diverging from ProcessMonitor
<SeanTAllen>
yes
<jemc>
and maybe call it something like ProcessSpawn
<SeanTAllen>
there's a small bit of C-FFI in _child in process monitor that uses execve to start the process, that's probably all you want/need
<Sargun>
And the waitpid bit
<SeanTAllen>
what waitpid bit?
<Sargun>
The part that captures the exit code and feeds it back up to the notifier
<SeanTAllen>
sorry, i just dont have the context to understand what you are asking
<SeanTAllen>
do you literally want to stop the process from operating to wait for a change in the child process state?
<aturley>
Sargun sorry, didn't mean to ghost, i had to take a call.
<Sargun>
SeanTAllen: I want to be able to get a message when the child process exits.
<Sargun>
and the return code / signal it exited with
<SeanTAllen>
ProcessMonitor can use waitpid which is a blocking operation because its specifically waiting for it to close down
<SeanTAllen>
if you do that in a different context then the scheduler thread you call waitpid in will be blocked until the other process exits
<Sargun>
Is there a way to avoid stalling the scheduler?
<Sargun>
i.e. dirty threads, or similar
<SeanTAllen>
no
<jemc>
the only way to "wait" for something in pony that doesn't stall a scheduler thread is waiting for I/O
<SeanTAllen>
you could look into using WNOHANG but I'm not very familiar with its semantics
<Sargun>
SeanTAllen: If I use WNOHANG, then I have to poll
<SeanTAllen>
you could look into if you can do what you want using async stuff where pony wraps up kqueue/epoll et al
<Sargun>
SeanTAllen: So, should I just extend iocp?
<SeanTAllen>
I do not know, I haven't ever looked into wait is available other than waitpid and waitid
<Sargun>
SeanTAllen: Couple more question, is pony_asio_event_send thread safe (Do I need to synch on it)?
<SeanTAllen>
what do you mean by "synch" on it?
<SeanTAllen>
do you have to have a mutex around it?
nisanharamati has joined #ponylang
inoas has joined #ponylang
<Sargun>
SeanTAllen: Correct.
<SeanTAllen>
that shouldnt be required.
<Sargun>
SeanTAllen: So, the rough approach I'm thinking of is having another background thread that runs pid = waitpid(-1, &status, 0); -- and then generates events, and sends them to pony_asio_event_send
<Sargun>
and then actors can "subscribe" to it.
<Sargun>
Or is there anywhere else to create a C module that generates waitpid events and sends them into pony in a way that actors can subscribe to them
<Sargun>
Or is there a better way to create pthreads in C that generate events and send it into pony in away that actors can subscribe to it
<Sargun>
I wish pony allowed me to create threads that were not shared
<Sargun>
Like, it seems kind of weird to put this into the asio bits
nisanharamati has quit []
<Sargun>
Why are signals processed via asio?
<dlowe>
it's the only sane way, really
<dlowe>
to support both signals and threads
<SeanTAllen>
Sargun because it would be a nightmare otherwise?
<SeanTAllen>
because you register signal handlers that are done by an actor, that actor might get scheduled on any thread, so the signal gets delivered via asio and from there to the handler in question
<slfritchie>
Why does Erlang convert nearly everything from non-Erlang code into messages? (NIFs don't count, they're a performance hack.)
<Sargun>
slfritchie: I think that it's perfectly fine to do that
<Sargun>
I'm just wondering where the best place to inject waitid events into the runtime is
<Sargun>
And I just PM'd you a more flushed out rust version
<Sargun>
of what I'm building
<Sargun>
Can't post it in channel
<Sargun>
So, this is a very simple tool -- basically, it launches a child, waits for a signal, does some processing when it gets that signal, and forwards the signal onwards
xllndr has joined #ponylang
<Sargun>
I don't want to do SIGCHLD, because (1) IF I ever want to supervise two processes -- how do I know what to do? (2) The period between the sigchld, and the waitpid means it'll stall the scheduler
<SeanTAllen>
I dont understand 2
<Sargun>
You still have to call waitpid after you get the sigchld
<Sargun>
and I'm not sure as to the guarantees about waitpid's professing -- of whether the status becomes immediately available after the SIGCHLD
<Sargun>
I kind of wish there was a way to schedule pony actors on dedicated threads, like Go does. It makes writing low-level code a lot easier without having to start hack the runtime, if you don't care about performance for that bit
<SeanTAllen>
I dont think I can help, I'm not sure how you want all this to interact with Pony's runtime. I've given a number of ways to do it and you have reasons for not doing any of them. It sounds like you want a program that will spin off threads, call waitpid after execing something and do nothing else. I'm not sure that Pony is a good fit for that, but I'm not sure because I dont really understand the use case. It doesn't seem
<SeanTAllen>
like a good fit to me though as you want control over threads and that seems to be pretty much it.
<Sargun>
What's wrong with having the waitpid handler code live in the asio bits?
<Sargun>
I think the approach to running pony directly from C might be usable as well
acarrico has quit [Ping timeout: 240 seconds]
<Sargun>
Pony's guarantees are a really nice fit for this, but the managed runtime is awkward here
<SeanTAllen>
i thought you said you didnt want to use epoll and the event system
<Sargun>
No, I'm fine using the event systrem
<Sargun>
I'm just not sure where the best place to integrate it is.
<SeanTAllen>
im not sure what has to be integrated
<SeanTAllen>
waitpid isnt evented
<SeanTAllen>
but there is that library i sent that does something for making it evented
<SeanTAllen>
not sure what they are doing so... couldnt really say what if anything needs to be done
<SeanTAllen>
everything might already be in place
infinitary has joined #ponylang
vaninwagen has joined #ponylang
user10032 has joined #ponylang
xllndr has quit [Quit: Leaving]
endformationage has joined #ponylang
endformationage has quit [Ping timeout: 265 seconds]
endformationage has joined #ponylang
endformationage has quit [Read error: Connection reset by peer]
endformationage has joined #ponylang
user10032 has quit [Quit: Leaving]
endformationage has quit [Ping timeout: 268 seconds]
endformationage has joined #ponylang
endformationage has quit [Ping timeout: 240 seconds]
endformationage has joined #ponylang
vaninwagen has quit [Quit: WeeChat 2.1]
endformationage has quit [Ping timeout: 240 seconds]
endformationage has joined #ponylang
infinitary has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
khan has quit [Quit: khan]
khan has joined #ponylang
endformationage has quit [Ping timeout: 260 seconds]
endformationage has joined #ponylang
khan has quit [Client Quit]
khan has joined #ponylang
<Sargun>
SeanTAllen: I'm trying to wire up the asio bits
<SeanTAllen>
ok
<SeanTAllen>
would love to see what you learn and how that goes...
<Sargun>
Who wrote this code?
endformationage has quit [Ping timeout: 265 seconds]
<SeanTAllen>
i dont know what code you are referring to
<jemc>
Sargun: note that you can use `git blame` (or GitHub's nice UI for it) to see who last commited to each particular line of a particular file
<Sargun>
Rather, the question I mean to ask -- who is the best person to ask questions for it
<SeanTAllen>
most of that dates back to Sylvan and Sebastian. Sebastian isn't involved in the project. Sylvan doesn't use IRC. An Andy who is no longer around did most of the iocp.c.
acarrico has joined #ponylang
_andre has quit [Quit: leaving]
<SeanTAllen>
like i said before, i'm not sure what is required to do what you want to do, i'm not sure that anything in there needs to be touched
<SeanTAllen>
iocp is windows specific, are you running on windows? for linux the epoll and kqueue stuff is what you would be interested in.
SenasOzys_ has quit [Remote host closed the connection]
SenasOzys has joined #ponylang
SenasOzys has quit [Remote host closed the connection]
SenasOzys has joined #ponylang
SenasOzys has quit [Remote host closed the connection]
SenasOzys has joined #ponylang
khan has quit [Quit: khan]
khan has joined #ponylang
endformationage has quit [Ping timeout: 265 seconds]