If your pillboxes are all at ground level and your marksdwarves can path to the outside then you might have issues.
I prefer to place my marksdwarves up one z-level from the surrounding terrain, this allows the free use of the move command without concern.
Generally if I have them in the pillboxes, the main gate isn't open. They are around the map edge set around the usual areas various squads spawn. If I get a siege, I lock the door, send out the two squads to soften them up a bit. If I can't reach any or something like that then I'll call them back. Closer to the main entrance I've got various walls at various Z-levels that have fortifications carved into them. Depending on which way the enemy might approach the gate, I can put some guys in there to cut them off. It all works very well until I feel the need to open the gate. If I worry I'm spending too much time on the siege and might miss a caravan, I'll send out my 9 legendary guys with adamantium to mop things up.
Today I thought I'd try stationing the guys while opening the door. I had 2 squads I couldn't quite get. One was too far from the box, and the other had an elite human crossbowman. If there is an elite archer, I tend to leave those squads to last. If the siege hasn't broken, I send out the melee troops. The elite guys inevitably kill a marksdwarf or two, or most of them.
I just wish you could set fortifications with a "side" or something and tell your guys to line up on that side.