whpthomas / GPX

Gcode to x3g conversion post processor
GNU General Public License v2.0
98 stars 16 forks source link

LOW PRIORITY: Test to close sio_port descriptor in exit_hander() makes a false assumption #14

Open dcnewman opened 9 years ago

dcnewman commented 9 years ago

In gpx-main.c/exit_handler(), the sio_port descriptor is only closed if it is > 2. That assumes that when it was opened, it was assigned a value of 3 or more. That won't be the case when the process is exec() and forked() in a context that doesn't open one or more of stdin, stdout, and stderr. That is, that test assumes that stdin=0, stdout=1, and stderr=3. That's not always true.

The test should be changed to "if(sio_port >= 0) close(sio_port);".