What is the military gain when compared to the suffering to the innocent. That is a key question that is asked
The problem is: how is a submarine commander to determine this? Or, for that matter, a bomber pilot or an artillery officer?
As I recall, every belligerent in WW II operated on the principle of "Unrestricted Submarine Warfare" -- which presumed that an enemy-flagged ship operating in a war zone was carrying military personnel and/or materiel. And, was, thus fair game. The only exception was hospital ships -- which were painted white and adorned with a red cross.
Civilians traveled thereon at their own risk...and were warned accordingly at the ports of embarkation.
At the same time, though, the principle of "Unrestricted Submarine Warfare" was a murky area within the international laws of war. Recall the >Lusitania incident in WW I. For that reason, I recollect that WW II public dispatches never identified submarine captains or crewmen by name.
A problem, indeed. That is why subs back then, and today, make an effort to determine the type and mission of the ship. . .except for Italy and Germany in WWII. I don't recall ALL belligerents engaged in unrestricted sub warfare. I believe we didn't do that.
Ref bomber pilots or artillery. . .spotters, forward air controllers and targeting Intel play that role.