This is an excellent question. Unfortunately, it seems that piracy in open seas is currently considered just a crime. Pirates are considered citizens, not terrorists or even military criminals, so their treatment is governed by human rights laws. For this reason, many countries are hesitant to capture and prosecute pirates. They don’t want to pay for jail costs and are afraid the criminals will be poorly treated when returned to the home countries.
With so many conflicting laws and without a comprehensive legal framework, many countries are advocating for piracy to be treated as terrorism. The advantages of designating piracy as terrorism would allow countries to prosecute pirates in the international court.