Unless the input file is a device, and then you need to call:
ioctl(STDIN_FILENO, BLKGETSIZE64, &size)
But I guess this is orthogonal to where the file descriptor comes from (i.e. stdin or opening a file whose name is passed in the args)
It's an orthogonal issue, yes, but calling stat or fstat on any block device whether from stdin or argv will return .st_size == 0, so your progress bar won't display the correct answers (or could display better answers if it used the ioctl).