MCPcopy Create free account
hub / github.com/coreutils/coreutils / zaptemp

Function zaptemp

src/sort.c:1354–1383  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1352/* Remove NAME from the list of temporary files. */
1353
1354static void
1355zaptemp (char const *name)
1356{
1357 struct tempnode *volatile *pnode;
1358 struct tempnode *node;
1359 struct tempnode *next;
1360 int unlink_status;
1361 int unlink_errno = 0;
1362 struct cs_status cs;
1363
1364 for (pnode = &temphead; (node = *pnode)->name != name; pnode = &node->next)
1365 continue;
1366
1367 if (node->state == UNREAPED)
1368 wait_proc (node->pid);
1369
1370 /* Unlink the temporary file in a critical section to avoid races. */
1371 next = node->next;
1372 cs_enter (&cs);
1373 unlink_status = unlink (name);
1374 unlink_errno = errno;
1375 *pnode = next;
1376 cs_leave (&cs);
1377
1378 if (unlink_status != 0)
1379 error (0, unlink_errno, _("warning: cannot remove: %s"), quotef (name));
1380 if (! next)
1381 temptail = pnode;
1382 free (node);
1383}
1384
1385#if HAVE_NL_LANGINFO
1386

Callers 1

mergefpsFunction · 0.85

Calls 3

wait_procFunction · 0.85
cs_enterFunction · 0.85
cs_leaveFunction · 0.85

Tested by

no test coverage detected