If a person attempts to commit suicide but fails in his attempt then he is liable for punishment under Section 309 of the IPC.
Section 309, IPC says that "Whoever attempts to commit suicide and does any act towards the commission of such offence, shall be punished with simple imprisonment for a term which may extend to one year, or with fine, or with both."
It is the only crime which is punishable in the stage of 'attempt' but nonpunishable if the act is completed.
This provision was declared unconstitutional and violative of Article 21 of the Constitution of India (Right to Life) in the case of P. Rathinam Vs. Union of India (1994) wherein the Supreme Court declared this provision as void as (besides other reasons) it is cruel and doubly punishes a person who has already suffered a lot in life. But eventually this decision was overruled by Supreme Court in the case of Gian Kaur Vs. State of Punjab (1996). The Court rejected the argument that the right to live with dignity also includes the corollary right to die as and when one feels necessary on the ground that living with dignity may no longer be possible.
Therefore the present position of law is that if a person attempts to commit suicide and does any ostensible or definitive act towards such attempt then he is liable to be punished u/s 309 of IPC. For example a man may buy kerosene and match stick, pour the kerosene on his body and light the matchstick. But he is not guilty of attempt to commit suicide. But the moment he lights himself, he becomes guilty under Section 309, IPC. Similarly if a woman runs to a well to jump in it & die and just at the mouth of the well people catch her. She is not guilty. But if she jumps and then people rescue her, she is liable under Section 309, IPC.
The test is that if the relevant action would have led to the achievement of the purpose had there been no external interference, then that is the stage where attempt is said to be complete and irreversible. At that stage only an act becomes an attempt and the person becomes liable for punishment.