diff --git a/cudax/examples/file.cu b/cudax/examples/file.cu index 67ebef5651e..b419bb6e4e0 100644 --- a/cudax/examples/file.cu +++ b/cudax/examples/file.cu @@ -119,7 +119,12 @@ try printf("waiting for the stream to finish\n"); stream.wait(); - if (numBytesWritten != numBytes) + if (numBytes == -1) + { + perror("Error writing file: "); + exit(EXIT_FAILURE); + } + else if (numBytesWritten != numBytes) { fprintf(stderr, "Error: wrote %ld bytes, expected %ld\n", numBytesWritten, numBytes); exit(EXIT_FAILURE);