Skip to content

Commit c547b05

Browse files
committed
driver: SigrokDriver avoid deadlock when sigrok-cli process failed
The driver expected that the sigrok-cli is successful and starts capturing in continuous mode. When the call is unsuccessful, the driver then waited for the creation of the capture file forever. Fixed by checking if the sigrok-cli process terminated prematurely while waiting for the existence of the capture file. Signed-off-by: Felix Zwettler <Felix.Zwettler@duagon.com>
1 parent b69ff84 commit c547b05

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

labgrid/driver/sigrokdriver.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,16 @@ def capture(self, filename, samplerate="200k"):
149149
args = self.sigrok.command_prefix + ['test', '-e', filename]
150150

151151
while subprocess.call(args):
152+
# in case the sigrok-cli call fails, this would wait forever.
153+
# to avoid this, we also check the spawned sigrok process
154+
if self._process.poll() is not None:
155+
ret = self._process.returncode
156+
if ret != 0:
157+
stdout, stderr = self._process.communicate()
158+
self.logger.debug("sigrok-cli call terminated prematurely with non-zero return-code")
159+
self.logger.debug("stdout: %s", stdout)
160+
self.logger.debug("stderr: %s", stderr)
161+
raise ExecutionError(f"sigrok-cli call terminated prematurely with return-code '{ret}'.")
152162
sleep(0.1)
153163

154164
self._running = True

0 commit comments

Comments
 (0)