System() vs. commandline?


#1

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


#2

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


#3

Dean W. 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 W.
http://www.aspectprogramming.com
http://www.newaspects.com
http://www.contract4j.org


#4

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 W.
http://www.aspectprogramming.com
http://www.newaspects.com
http://www.contract4j.org