cahirwpz/mimiker

ls_rec throws EBADF at close(fd)

Closed this issue · 1 comments

When I move line 14:

unix.close(fd)

... after the loop and run /bin/ls_rec I get following message:

[ dir, ino=2] /.
[ dir, ino=2] /..
[file, ino=3] /mimiker.ld
[ dir, ino=4] /lib
[ dir, ino=4] /lib/.
[ dir, ino=2] /lib/..
[ dir, ino=5] /lib/lua
[ dir, ino=5] /lib/lua/.
[ dir, ino=4] /lib/lua/..
[file, ino=6] /lib/lua/init.lua
/bin/lua: 9
stack traceback:
	[C]: in function 'unix.close'
	/bin/ls_rec:23: in function 'list_recursive'
	/bin/ls_rec:20: in function 'list_recursive'
	/bin/ls_rec:26: in main chunk
	[C]: in ?
Child exited with 256

Hmm... that was my mistake after all. Apparently variable bindings in Lua do not work as I'd expect them to. It was necessary to add local keyword to fd variable.