Note that we may call this function in signal handle 'sigShutdownHandler', * so we need guarantee all functions we call are async-signal-safe. * If we call this function from signal handle, we won't call bg_unlink that * is not async-signal-safe. */
| 1461 | * If we call this function from signal handle, we won't call bg_unlink that |
| 1462 | * is not async-signal-safe. */ |
| 1463 | void rdbRemoveTempFile(pid_t childpid, int from_signal) { |
| 1464 | char tmpfile[256]; |
| 1465 | char pid[32]; |
| 1466 | |
| 1467 | /* Generate temp rdb file name using aync-signal safe functions. */ |
| 1468 | int pid_len = ll2string(pid, sizeof(pid), childpid); |
| 1469 | strcpy(tmpfile, "temp-"); |
| 1470 | strncpy(tmpfile+5, pid, pid_len); |
| 1471 | strcpy(tmpfile+5+pid_len, ".rdb"); |
| 1472 | |
| 1473 | if (from_signal) { |
| 1474 | /* bg_unlink is not async-signal-safe, but in this case we don't really |
| 1475 | * need to close the fd, it'll be released when the process exists. */ |
| 1476 | int fd = open(tmpfile, O_RDONLY|O_NONBLOCK); |
| 1477 | UNUSED(fd); |
| 1478 | unlink(tmpfile); |
| 1479 | } else { |
| 1480 | bg_unlink(tmpfile); |
| 1481 | } |
| 1482 | } |
| 1483 | |
| 1484 | /* This function is called by rdbLoadObject() when the code is in RDB-check |
| 1485 | * mode and we find a module value of type 2 that can be parsed without |
no test coverage detected