Closed tmm1 closed 13 years ago
The failing test in question is
def test_spawn_close_invalid_fd_raises_exception
pid = _spawn("echo", "hiya", 250 => :close)
assert_process_exit_status pid, 127
rescue Errno::EBADF
# this happens on darwin only. GNU does spawn and exits 127.
end
and it only fails when using the POSIX::Spawn.pspawn
. For some reason, posix_spawn_file_actions_addclose(fops, 250)
does not fail.
@evanphx any ideas? is it possible 250 is a valid file descriptor on rbx for some reason?
Wow I completely screwed that up. The actual failure is in redirect_invalid_fd
, not close_invalid_fd
. The code is
def test_spawn_redirect_invalid_fds_raises_exception
pid = _spawn("echo", "hiya", 250 => 3)
assert_process_exit_status pid, 127
rescue Errno::EBADF
# this happens on darwin only. GNU does spawn and exits 127.
end
and it's actually the posix_spawn_file_actions_adddup2(fops, 3, 250)
that's not erroring out as expected.
Isolated repro:
cat extconf.rb
require 'mkmf'
$CFLAGS << " -Wall -O0 -ggdb "
create_makefile('posix_spawn_test')
cat test.c
#define _GNU_SOURCE
#endif
#include <assert.h>
#include <errno.h>
#include <ruby.h>
#include <spawn.h>
#include <stdio.h>
void
Init_posix_spawn_test()
{
int ret;
posix_spawn_file_actions_t fops;
pid_t pid;
char *cargv[3] = {"echo", "hiya", NULL};
posix_spawn_file_actions_init(&fops);
posix_spawn_file_actions_adddup2(&fops, 3, 250);
ret = posix_spawnp(&pid, cargv[0], &fops, NULL, cargv, NULL);
printf("ret: %d\n", ret);
}
ruby -v && ruby extconf.rb && make && ruby -e' require "posix_spawn_test" '
ruby 1.8.7 (2010-12-23 patchlevel 330) [i686-darwin10.5.0]
creating Makefile
cc -dynamic -bundle -undefined suppress -flat_namespace -o posix_spawn_test.bundle test.o -L. -lruby -ldl -lobjc
ret: 9
ruby -v && ruby extconf.rb && make && ruby -e' require "posix_spawn_test" '
rubinius 1.2.4dev (1.8.7 18066d4d yyyy-mm-dd JI) [x86_64-apple-darwin10.6.0]
creating Makefile
gcc -dynamic -bundle -undefined suppress -flat_namespace -o posix_spawn_test.bundle test.o -L.
ret: 0
hiya
I don't see why this should fail on MRI even. Isn't "posix_spawn_file_actions_adddup2" saying "take the kernel object at descriptor 3 and also reference it at descriptor 250" ?
You're right, the test is wrong. It's failing on rbx because there is actually no fd 3 created in the test, and 3 just happens to be valid during the test in MRI.
Fix invalid fd redirect test (closed by 152f32a03556eda67049337cd977ae69af817476)
@brynary I just pushed out a 0.3.4 gem that should work on rbx
You guys rock. Thanks.
I fixed compilation issues and a couple other test failures against the latest rbx release, but couldn't figure out what's causing this failure: