planck

Planck ClojureScript REPL
johanatan 2016-06-22T00:02:00.000117Z

[a similar method (redirecting both stdout and stderr to files instead of just stderr) is demonstrated here (in the OP): http://stackoverflow.com/questions/15155314/redirect-stdout-and-stderr-to-the-same-file-and-restore-it]

mfikes 2016-06-22T00:03:28.000119Z

I’m wondering what clojure.java.shell ends up causing Java to do at the OS level.

mfikes 2016-06-22T00:09:16.000120Z

@johanatan: I’ll read up on the popen / fork / pipe business. I’ve never tried doing things things at this level before 🙂

johanatan 2016-06-22T00:10:29.000121Z

ok, my preferred approach would be the popen()/`freopen()` combination mentioned above [as it's the least complex to implement] (assuming you're ok with temp files).

mfikes 2016-06-22T00:11:05.000122Z

Sounds like temp files would work, but obviously not a desired outcome if it can be avoided. (I don’t understand the APIs yet.)

mfikes 2016-06-22T00:12:04.000123Z

If nothing else, perhaps a temp-file based approach could be implemented and then we could revisit it as we learn more.

johanatan 2016-06-22T00:13:25.000124Z

Well, I think the next best option would be the one I mentioned earlier

johanatan 2016-06-22T00:13:29.000125Z

Inspired by kangear's post

johanatan 2016-06-22T00:13:43.000126Z

but it will be probably 100-120 lines of C instead of like 15 lines 🙂

johanatan 2016-06-22T00:14:22.000127Z

but i will wait for you to do some research and come to some conclusions as well. perhaps there is something my research has missed

johanatan 2016-06-22T00:15:02.000128Z

[also, i was thinking it would be nice if there were some sort of 3rd party C library out there which handles this-- i'd imagine any sort of higher-level OS abstraction library would support this sort of thing]

johanatan 2016-06-22T00:15:24.000129Z

[but I don't know if adding a dependency like that would be desirable or not]

mfikes 2016-06-22T01:34:56.000130Z

@johanatan: I don’t know if this leads to the ability to construct a solution, but it can evidently be done with 3 pipes. In this gist, I gave errfd a questionable variable name (because I was confused with what I was doing), but, it seems to work: https://gist.github.com/mfikes/52332f568be9da2dd72ee9376e5b9f34

mfikes 2016-06-22T01:38:15.000131Z

@johanatan: It is true that it is a decent amount of code to cobble together. (And there is probably some sort of select stuff that really needs to be done.) If it is more than you’d like to take on, certainly don’t feel obligated.

johanatan 2016-06-22T05:27:41.000132Z

yes, that's the "solution inspired by kangear" I referred to. 🙂 no, it's not too much work for me

johanatan 2016-06-22T05:29:02.000133Z

oops, sorry. that's a different solution involving a manual fork() and execv() rather than popen(). i remember running across that one too

johanatan 2016-06-22T05:31:18.000134Z

i just wanted to make sure we agreed on the approach before I coded it. thx!

mfikes 2016-06-22T16:12:15.000138Z

@johanatan: Yeah… if a solution can be built using pipes rather than tmp files, I think it’s worth it, given that sh is a pretty key feature, even if it involves a decent amount of code.

johanatan 2016-06-22T16:12:26.000139Z

@mfikes: ok, cool