Edit: I discovered that the problem is not related with the script cited below, but I'll leave it there just for history. Well, this error appears when I close texstudio with the viewer open (xdvi or ...
I am creating a script to produce some .tex files with a lot of lines (a kind of automatic sample). The script finishes with texstudio /home/$USER/foo.tex where foo.tex is the file created before. ...