System call bizarre behavior
4 次查看(过去 30 天)
显示 更早的评论
I have a problem running Matlab 2017a on Centos 7. System/Unix calls will occasionally fail the first time they are called. The error received is "bang: poll [4] interrupted system call". The following call will then return the results of the proceeding call.
>> system('echo dogbone')
Error using system
Unexpected system error: bang: poll [4] Interrupted system call
>> system('echo dogbone1');
dogbone
>> system('echo dogbone2');
dogbone1
>> system('echo dogbone3');
dogbone2
I have never seen anything like this, and it's very frustrating. It only appears occasionally, but I can replicate it consistently by ssh-ing from another machine, like so:
ssh -X user@machine 'matlab -nodesktop'
Any Thoughts?
0 个评论
回答(5 个)
Michael Pelletier
2018-2-19
编辑:Michael Pelletier
2018-2-19
I found the root cause of this via an strace of the MATLAB process. It revealed this tidbit shortly after the attempt to run the first system() invocation:
553435 ioctl(3, SNDRV_TIMER_IOCTL_SELECT or TIOCSPGRP, [553435]) = -1 ENOTTY (Inappropriate ioctl for device)
The "ENOTTY" means that the ioctl() call is inapplicable because the session is not associated with a pseudo-tty. And the reason that a poll() error comes back is because the thread reporting the error is not the one actually doing the fork/exec - it just sent a message to the thread that does. And so when the fork/exec thread fails, the poll() waiting for the response from that thread is interrupted.
The fix is to use the "-t" option for SSH, that is:
ssh -t -X user@machine 'matlab -nodesktop'
This forces the SSH server to allocate a pseudo-tty to the MATLAB process' environment whether it thinks it needs it or not, and so the ENOTTY error is avoided, and so allows the first system() call, and all subsequent system() calls, to work as expected.
0 个评论
Sharath Chandran
2017-10-13
编辑:Sharath Chandran
2017-10-13
Hi Paul,
Could you please try sourcing .bash_profile prior to calling MATLAB?
If you are trying to launch MATLAB remotely on a different machine, then I would suggest you to try following:
$ ssh -l user@remoteSystem /bin/bash -c "matlab -nodisplay -nodesktop -noFigureWindows -r testScript.m"
where 'testScript.m' contains the command : system('echo dogbone'). Probably specifying the shell name, like above, works (since it reads .bash_profile while logging in using bash shell).
The difference probably is whether bash is in login mode or interactive mode (when .bash_profile is read) when invoking MATLAB in remote workflow.
I hope this helps.
Regards,
MathWorks Technical Support
1 个评论
Michael Pelletier
2018-1-9
What information or service is MATLAB looking to obtain from the shell? Are there environment variables it's looking for, etc? This seems to be a change of behavior from prior releases - we've been running tens of thousands of MATLAB distributed compute jobs in a compute cluster without a shell for years.
Jordan
2017-11-26
I obtain this same behaviour when I launch matlab and make system() calls within a VNC session, then ssh into my server from a different machine to check on how my system() job is going in the VNC session. Doing so causes an error in whatever job was running in the interactive matlab shell.
"Unexpected system error: bang: poll [4] Interrupted system call"
...followed by the same bizarre behaviour reported above. I am running Matlab 2017a on Ubuntu 16.04.3.
0 个评论
Michael Pelletier
2018-2-13
This problem also plagues my code to submit HTCondor jobs from Windows machines, because it uses SSH to reach a machine where it can run condor_submit, if HTCondor is not installed on the Windows machine. If there's no answer to this, looks like I may be forced to do a try/catch along with a dummy second call to get any results, such as the job ID number.
0 个评论
Max Rudolph
2018-5-2
编辑:Max Rudolph
2018-5-2
I am having this problem as well, and it renders MATLAB essentially useless for common tasks that require me to invoke an external program. I also have R2017a on Ubuntu 18 LTS. I have additional, even more bizarre behavior. Sometimes MATLAB cannot find files in the cwd the first time, but they appear by running 'ls' twice: >> ls geoid.ab >> ls geoid.ab geoid.ab
>>
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!