as long as he shall have behaved well (legal Latin)
I.e., "[while on] good behavior." So for example the Act of Settlement 1701 stipulated that judges' commissions are valid quamdiu se bene gesserint (during good behaviour). (Notice the different singular, "gesserit", and plural, "gesserint", forms.) It was from this phrase that Frank Herbert extracted the name for the Bene Gesserit sisterhood in the Dune novels.
A much more detailed analysis with detection of relationships or clauses can be found in our Sentence Analysis! Try it out!