ayrnieu changed the topic of #ocaml to: OCaml 3.08.4 available! Archive of Caml Weekly News: http://sardes.inrialpes.fr/~aschmitt/cwn/ | A free book: http://cristal.inria.fr/~remy/cours/appsem/ | Mailing List: http://caml.inria.fr/bin/wilma/caml-list/ | Cookbook: http://pleac.sourceforge.net/
Schmurtz has quit [Read error: 104 (Connection reset by peer)]
cmeme has quit ["Client terminated by server"]
cmeme has joined #ocaml
cmeme has quit [Client Quit]
cmeme has joined #ocaml
tom_p has joined #ocaml
Skal has quit [Remote closed the connection]
smimou has quit ["bli"]
<KrispyKringle> Is there an equivalent to mktemp in the standard modules? Something to make a temporary file easily?
estelle is now known as vgoo
<KrispyKringle> oh, nevermind.
<vgoo> KrispyKringle: Filename.(?)
<vgoo> temp_file
<KrispyKringle> yeah
<KrispyKringle> I found it :)
<KrispyKringle> thanks, though
<KrispyKringle> Hmm. I want to pipe a string to a program executed with Unix.system (or whatever). Do I have to create a pipe, and use Unix.dup to set the output of the pipe to the stdin filehandle, and then fork, etc, or is there a cleaner weay to do it?
<Submarine> why don't you use popen
<Submarine> val open_process_out : string -> out_channel
<Submarine> Same as Unix.open_process_in, but redirect the standard input of the command to a pipe. Data written to the returned output channel is sent to the standard input of the command. Warning: writes on output channels are buffered, hence be careful to call flush at the right times to ensure correct synchronization.
<Submarine> read doc of Unix module
<KrispyKringle> ah, thanks. Didn't see that one.
<KrispyKringle> Hmm. But that doesn't return the process's exit status, eh?
<KrispyKringle> or PID so I can get that status.
<Submarine> if you're under Unix you can do that manually, as in C
<Submarine> I know it's painful
<KrispyKringle> yeah, i know.
<KrispyKringle> but the alternative is for me to be messy and create a tmp file insteaed.
<KrispyKringle> which I think I'll do for now and fix later, if it's a problem.
brx has quit [Remote closed the connection]
vezenchio has joined #ocaml
vincenz has quit ["leaving"]
Submarine has quit ["Leaving"]
pango__ has joined #ocaml
<KrispyKringle> Oh my god. I googled for a problem I'm having right now, and I found IRC logs of me asking in here about a similar problem.
<KrispyKringle> Jesus.
descender has joined #ocaml
pango_ has quit [Read error: 110 (Connection timed out)]
dfgp has quit [Read error: 110 (Connection timed out)]
mercurylala has quit ["Leaving"]
albertelegance has joined #ocaml
lispy is now known as Hugus_Twang
kryptt has joined #ocaml
albertelegance has quit ["Leaving"]
shirogane has joined #ocaml
Snark has joined #ocaml
<KrispyKringle> So this (http://rafb.net/paste/results/qGQUHx30.html) seems broken. Specifically, it seems like the child process I create (gpg) sleeps because it's blocking on either input or output. Now, I close the input file handle, so that shouldn't block (it should hit EOF on STDIN, IOW).
<KrispyKringle> But the output filehandle I don't read from until after I've created the process. But I assume it can write to and close the other end of the pipe before I read from it (I don't remember how pipes work all that well, to be honest).
<KrispyKringle> Thanks.
<KrispyKringle> Any ideas?
<Snark> what happens when you launch the command by hand ?
<KrispyKringle> works fine.
<KrispyKringle> It also works fine if I do "system" and don't mess with the STDIN or STDOUT
<KrispyKringle> It's the piping that's got it blocking.
<KrispyKringle> But to my recollectoin, I shouldn't have to read from the other end of the StDOUT pipe
<KrispyKringle> I don't think.
__DL__ has joined #ocaml
chs_ has quit []
ellisonch has joined #ocaml
<mflux_> krispykringle, hmm.. if you don't read gpg's stdout, what will?
<KrispyKringle> mflux_: I assumed it could still write to the other end of the pipe, though.
<KrispyKringle> Anyway, I'm going to hit the hay. Too late to get anything done anyway. If you have any comments, I'd appreciate it, though. I'll check back in the morning. :)
<mflux_> krispykringle, got an url for the code?
Skal has joined #ocaml
pango__ is now known as pango
Submarine has joined #ocaml
skylan_ has joined #ocaml
skylan has quit [Connection timed out]
dfgp has joined #ocaml
shirogane has quit [Read error: 104 (Connection reset by peer)]
Chipster1 has joined #ocaml
<Chipster1> salut all
revision17_ has joined #ocaml
Chipster1 has left #ocaml []
Revision17 has quit [Read error: 110 (Connection timed out)]
ChipsterOne has joined #ocaml
smimou has joined #ocaml
Oatmeat has joined #ocaml
Oatly has quit [Read error: 110 (Connection timed out)]
ChipsterOne has left #ocaml []
brx has joined #ocaml
vgoo is now known as vegie-goo
vegie-goo is now known as verge-goo
Submarine is now known as SubbyOnWheels
SubbyOnWheels is now known as Submarine
ChipsterOne has joined #ocaml
ChipsterOne has quit []
Oatly has joined #ocaml
dfgp has quit [Read error: 113 (No route to host)]
ChipsterOne has joined #ocaml
Oatmeat has quit [Read error: 110 (Connection timed out)]
ChipsterOne has left #ocaml []
ChipsterOne has joined #ocaml
ChipsterOne has left #ocaml []
kryptt has quit [Read error: 110 (Connection timed out)]
Skal has quit [Remote closed the connection]
_JusSx_ has joined #ocaml
smimou has quit ["bli"]
Skal has joined #ocaml
smimou has joined #ocaml
chs_ has joined #ocaml
vezenchio has quit ["\o/ toki ni wa motto watashi-rashiku kaze o kanjitai - dare demo nai watashi no mirai o mitsuketakute \o/"]
brx has quit [Read error: 110 (Connection timed out)]
brx has joined #ocaml
mauke has quit [Remote closed the connection]
mauke has joined #ocaml
dfgp has joined #ocaml
albertelegance has joined #ocaml
ChipsterOne has joined #ocaml
ChipsterOne has left #ocaml []
verge-goo is now known as drpingouin
shirogane has joined #ocaml
<KrispyKringle> mflux_: That's all the code I have. I can give you the file, if you'd like, but what I put on Pastebin is really the entire function.
<mflux_> gah, I totally missed the url, it was so much up ;)
<KrispyKringle> mflux_: Ah, ok. One sec :)
<mflux_> krispykringle, how much data are you feeding to the process?
<KrispyKringle> I have a sucessful implementation with tmp files, but I was a) hoping to do it with a pipe and b) eventually I need to grab thhe STDOUT of gpg, too, so I can read what key it was that signed it.
<KrispyKringle> mflux_: Not much. 319 bytes.
<mflux_> krispykringle, have you checked out the line where it stalls?
<KrispyKringle> mflux_: Well, the gpg process sleeps (I can verify that with ps), and since I'm waitpid'ing on it, so does the parent process.
<KrispyKringle> What I can't figure out is why GPG sleeps.
<mflux_> hm, btw, that's a nice way of defining a function, I hadn't thought of that although I had missed that syntax
<KrispyKringle> If I kill GPG extyernally, then my code finishes just fine.
<KrispyKringle> on sec, phone
<mflux_> krispykringle, gpg isn't actually sleep(2)ing, isn't it? how about doing a strace(1) on it?
ChipsterOne has joined #ocaml
ChipsterOne has left #ocaml []
<Snark> mflux_: is it possible to strace any app ?
<Snark> I thought it had to be launched with strace already
<Snark> s/app/process/
<pango> Snark: strace -p pid
<Snark> pango: wahoo..
<Snark> wonderful
<Snark> but if the thing is sleeping, it will probably not give much
<Snark> unless there's a way to create the process asleep, get its pid, attach ptrace then run it
<pango> strace -f the parent process ?
<pango> then all forked processes get straces as well
<Snark> or write a script, which calls strace gpg... and exec that instead
<pango> yes
<mflux_> snark, I doubt it's sleeping, it's more propably trying to write or read
<mflux_> and it will show what system call the process is 'stuck' in
<mflux_> but if it is sleeping, that's valuable information too ;)
<KrispyKringle> mflux_: I meant its state was S; presumably it's blocking on either STDIN or STDOUT.
<KrispyKringle> A simple test would be for me to run it with stdout as its output and see what happens, actually.
<KrispyKringle> Does create_process create a process that's halted?
<KrispyKringle> do I need to signal it first?
<mflux_> krispykringle, did you try strace?
<KrispyKringle> mflux_: Not yet. Just got off the phone with a very angry person. ;)
<mflux_> hm, infact I think I spotted one problem
<KrispyKringle> Yes?
<mflux_> you want to wait the process after the read, not before
<KrispyKringle> After I read the output? See, that's what I was wondering:
<KrispyKringle> But since a pipe is asynchronous, gpg should be able to write to it even if I'm not reading from it, no?
<mflux_> yes
descender has quit [Remote closed the connection]
<KrispyKringle> So I don't know why I should have to read from it until after the process is done, anyway.
<KrispyKringle> Anyway, I'm on OSX. There's ktrace, but I'm not all that familiar with it.
<mflux_> well, for one, if there is a lot of data coming in, it would not be asynchronous anymore
<KrispyKringle> There's not much. About a couple hundred bytes.
<mflux_> well, you could simply try it anyway?
<KrispyKringle> Right. I did try putting the read in a while loop that does WNOHANG waits (i.e. checks each time around the loop to see if the process is dead yet).
<KrispyKringle> Which is obviously silly, but worth trying. Didn't work, though.
<mflux_> what's the point of waiting anyway? other than to reap zombies that is
<mflux_> if are you attempting to read the whole data in one read or something
<KrispyKringle> mflux_: Hmm? I want to wait until the process is entirely done printing to stdout before I continue.
<mflux_> you should infact loop on the read until you reach EOF
<KrispyKringle> ah, that's a good point.
<mflux_> which obviously indicates terminated process
<mflux_> after which you should reap the child with waitpid
<KrispyKringle> yes, that's a very good point.
<KrispyKringle> hmm.
<KrispyKringle> Thanks. :)
<KrispyKringle> Yeah, if I give it the Unix.stdin and Unix.stdout as its file handles, it doesn't block.
<KrispyKringle> hrm.
<KrispyKringle> Ah, so gpg blocks on its stdin if I try to pipe the data to it rather than doing the tmp file thing. Now, I close the file handle after writing to it, so it should get an EOF, no?
<mflux_> yes
<KrispyKringle> I'm going to try it with Unix.open_process and channels instead. I didn't realize I could do it much more concisely than with pipes, in any case.
<KrispyKringle> Though as a result, I won't get the exit status. hmm.
<mflux_> well, I've written code that does half of what your code does (it's interested only in the output of the process)
<KrispyKringle> care to share? :P
<mflux_> I ended up not using those interfaces but fork+dup etc
<KrispyKringle> ah, yeah
<KrispyKringle> i was hoping to avoid that, but whatever.
<mflux_> well, unfortunately the code is in a 14 gigabyte tar.gz (I have my server down), plus it if memory serves, it is integrated with all kinds of other stuff
<mflux_> I put the machine to uncompress my sources from the archive, I'll get back to you if I find something useful ;)
<KrispyKringle> .jesus
<KrispyKringle> don't worry about it.
<KrispyKringle> ;)
<mflux_> (btw: it is a very good idea to backup your machines to other machines in your network ;))
<KrispyKringle> oh, score, i got it to work.
<KrispyKringle> now the big downside is that because I'm using Unix.open_process, which doesn't give me the process's pid, I don't know its exit status. But I can get the same info from the stdout anyway.
tom_p has quit [Success]
<KrispyKringle> oh, damn. only im not getting the output of the process. it's just printing to the terminal.
tom_p has joined #ocaml
Oatmeat has joined #ocaml
<KrispyKringle> because GPG prints to STDERR, not STDOUT. Goddamn you, GPG!
<KrispyKringle> OK. I'm done. I got it to work. I'm going to shoot myself, but that's OK. Thanks for the help, mflux_.
<mflux_> happy to be of help
Oatly has quit [Read error: 110 (Connection timed out)]
tom_p has quit [Connection timed out]
skylan_ is now known as skylan
Submarine has quit ["Leaving"]
Submarine has joined #ocaml
* Submarine floating-point maven
m3ga has joined #ocaml
descender has joined #ocaml
tirkal has joined #ocaml
tirkal has left #ocaml []
<pango> CommonSources.iter_files is probably a good candidate for optimization...
<pango> count_file_ready_sources and count_ready_sources get called left and right...
<pango> oups wrong channel ;)
Chipster1 has joined #ocaml
dfgp_ has joined #ocaml
dfgp has quit [Read error: 113 (No route to host)]
Hugus_Twang is now known as lispy
Chipster1 has left #ocaml []
ChipsterOne has joined #ocaml
m3ga has quit ["Client exiting"]
ChipsterOne has quit []
ChipsterOne has joined #ocaml
ChipsterOne has left #ocaml []
tom_p has joined #ocaml
shirogane has quit [Read error: 104 (Connection reset by peer)]
Snark has quit ["Parti"]
hyakume- has joined #ocaml
<hyakume-> hello
__DL__ has quit ["Bye Bye"]
Bigb[a]ng is now known as Bigbang
hyakume- has left #ocaml []
tom_p has quit [Success]
tom_p has joined #ocaml
tom_p has quit [Connection timed out]
_JusSx_ has quit ["leaving"]
Submarine has left #ocaml []
exa has quit [Remote closed the connection]
smimou has quit ["bli"]
Bigbang is now known as Bigb[a]ng
mlh_away has joined #ocaml
mlh_away is now known as mlh_
mlh_ has quit [Read error: 104 (Connection reset by peer)]
dfgp_ has quit [Read error: 104 (Connection reset by peer)]
dfgp has joined #ocaml
skylan is now known as skylan_
skylan_ is now known as skylan
mlh_away has joined #ocaml
Skal has quit ["Client exiting"]