Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

safe vs. unsafe FFI calls #1

Closed
iustin opened this issue Dec 31, 2014 · 4 comments
Closed

safe vs. unsafe FFI calls #1

iustin opened this issue Dec 31, 2014 · 4 comments

Comments

@iustin
Copy link

iustin commented Dec 31, 2014

The import of statvfs is:

foreign import ccall unsafe statvfs :: CString -> Ptr a -> IO CInt

Since this function is doing a system call, I'm not sure why it is marked as unsafe - in case of remote filesystems, this could block for a long time (in real world terms). What do you think about making this safe, since the overhead of the syscall will anyway make the Haskell RTS overhead most likely moot?

@redneb
Copy link
Owner

redneb commented Dec 31, 2014

I don't feel strongly about either way. I was merely following the convention followed by other packages that system calls that do not generally block are imported as unsafe. Examples of that are unlink(2), rename(2), chown(2), stat(2) in the unix package. All of those function suffer from the same possible issue that you mention.

@iustin
Copy link
Author

iustin commented Dec 31, 2014

Interesting, thanks for the info - I'll followup there and then update this issue.

@iustin
Copy link
Author

iustin commented Jan 5, 2015

FYI, on haskell/unix#34, the agreement is that unsafe is the wrong approach. I'll try to send a pull request later this week (if you don't beat me to it).

redneb added a commit that referenced this issue Jan 5, 2015
@redneb
Copy link
Owner

redneb commented Jan 5, 2015

I just uploaded a new version (v0.1.0.1) on hackage for that. Thanks for the report.

@redneb redneb closed this as completed Jan 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants