#include #include #include #include #include #include int main(void) { CK_RV rv; CK_FUNCTION_LIST_PTR funcs; pid_t pid; int st; rv = C_GetFunctionList(&funcs); if (rv != CKR_OK) { printf("Failed to get PKCS#11 function list\n"); exit(1); } rv = funcs->C_Initialize(NULL); if (rv != CKR_OK) { printf("Failed to initialize module\n"); exit(1); } pid = fork(); if (!pid) { rv = funcs->C_Initialize(NULL); if (rv != CKR_OK) { printf("Failed to re-initialize module in child\n"); exit(1); } exit(0); } else if (pid < 0) { perror("Fork failed"); exit(1); } waitpid(pid, &st, 0); printf("Done. %d\n", st); return st; }