J-M-L
2
It is by design that the Arduino resets when the PC opens the serial port
A possible solution is to use a USB to serial cable (FTDI cable - USB-ttl cable) connected directly to pins 0 and 1
There are other options documented on the internet like
(First random Google hit)