Frederik Siepe
Frederik Siepe

Reputation: 129

POSIX open() hangs on SMB share

I have a problem where I mount a Windows SMB share under linux with mount.cifs and write to files from my C++ program. This works fine, but as soon as network problems arise (i.e. Windows server disconnect), opening the file with POSIX open() will hang indefinitely. The same happens for the POSIX close() call if the share disconnects while the file is open. Using std::ofstream reveals a similar problem.

Is there

Upvotes: 3

Views: 306

Answers (1)

rveerd
rveerd

Reputation: 4006

Syscalls are interrupted when a signal arrives; errno will return EINTR.

You can use alarm() before the syscall to schedule SIGALRM after a time-out period.

You can also use alarm() to cancel a pending SIGARLM if the syscalls returns successfully before the time-out period expires.

Upvotes: 3

Related Questions