---
name: "sttransaction"
section: "3"
platform: "linux"
package: "atfs-dev"
version: "1.4pl6-15+b1"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/sttransaction"
---

# sttransaction(3)

simple transaction handling

## NAME

stAbortThis, stThisTransaction - simple transaction handling

## SYNOPSIS

\#include \<config.h\>\
 \#include \<sttk.h\>

void	stAbortThis (int domsg);

struct stTransaction	stThisTransaction;

## DESCRIPTION

*stAbortThis* is part of a simple transaction mechanism on the basis of [setjmp(3)](/setjmp/3.md) and [longjmp(3)](/longjmp/3.md). A transacion is started by setting a return point calling [setjmp(3)](/setjmp/3.md) and may be aborted by calling stAbortThis. This outputs a short abort message, cleans up the temporary files ([stRmRegisteredFiles(3)](/stRmRegisteredFiles/3.md)) and performs a [longjmp(3)](/longjmp/3.md) operation, returning to the transaction start point.

The structure variable *stThisTransaction* carries information about the current transaction. It has the following fields:

```
struct stTransaction {
  char tr_fname[MAXPATHLEN+1];
  int tr_done;
  int tr_seqno;
  int tr_rc;
  jmp_buf tr_env;
};
```

When setting the transaction return point by calling [setjmp(3)](/setjmp/3.md) the *tr\_env* field must be used as argument to setjmp. The name of the concerned file should be stored in *tr\_fname* field and the *tr\_done* flag should be cleared. *tr\_seqno* is the serial number of the current transaction and must be increased at the beginning of each new transaction. The *tr\_rc* return code can be set to an appropriate return code when something went wrong and the transaction was aborted. When not set by the application, *tr\_rc* will be set nun null by stAbortThis on abortion of the transaction. On successful completion, *tr\_done* should be set TRUE.

## SEE ALSO

[stRmRegisteredFiles(3)](/stRmRegisteredFiles/3.md), [setjmp(3)](/setjmp/3.md), [longjmp(3)](/longjmp/3.md).
