Forum: Ruby system() vs. commandline?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
429500a5a54600958c9c7ac032a37f66?d=identicon&s=25 Joe (Guest)
on 2006-05-03 03:13
I have a C program that processes text files. When I run it from the
commandline, it works fine. But if I run it via Ruby with
'system("textproc input output")' that output file usually gets
truncated near its end. The docs state:

"one of the exec(2) system calls is used, so the running command may
inherit some of the environment of the original program (including open
file descriptors)"

Is there some setting for Ruby which could be causing this problem -
such as a memory limit? I don't get any error messages whatsoever. I've
also tried exec() and popen(), with the same results.

Thanks,
Joe
Redhat FC4
Ruby 1.8.4
429500a5a54600958c9c7ac032a37f66?d=identicon&s=25 Joe (Guest)
on 2006-05-03 04:08
I rewrote the script in PHP and it all works fine. If anybody has any
insights or guesses why Ruby causes it to choke, please feel free!

Joe
F690ec04b0501b74b033fc64ff4f682b?d=identicon&s=25 Dean Wampler (Guest)
on 2006-05-03 19:06
(Received via mailing list)
When you say "truncated near the end", is that the last line of text
that gets chopped? Last 1 or few characters? Does the C program close
all open file handles, etc.? Also, what platform are you on?

dean

--
Dean Wampler
http://www.aspectprogramming.com
http://www.newaspects.com
http://www.contract4j.org
429500a5a54600958c9c7ac032a37f66?d=identicon&s=25 Joe (Guest)
on 2006-05-03 20:39
Dean Wampler wrote:
> When you say "truncated near the end", is that the last line of text
> that gets chopped? Last 1 or few characters?

No, it's the last page or so of text that gets truncated, in the middle
of paragraphs.

> Does the C program close
> all open file handles, etc.?

AFAIK. I didn't write it. But it works fine with everything else besides
Ruby.

> Also, what platform are you on?

Redhat FC4

Joe


>
> dean
>
> --
> Dean Wampler
> http://www.aspectprogramming.com
> http://www.newaspects.com
> http://www.contract4j.org
This topic is locked and can not be replied to.