MCPcopy Create free account
hub / github.com/F-Stack/f-stack / uu_lock_txfr

Function uu_lock_txfr

tools/libutil/uucplock.c:127–146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125}
126
127int
128uu_lock_txfr(const char *tty_name, pid_t pid)
129{
130 int fd, err;
131 char lckname[sizeof(_PATH_UUCPLOCK) + MAXNAMLEN];
132
133 snprintf(lckname, sizeof(lckname), _PATH_UUCPLOCK LOCKFMT, tty_name);
134
135 if ((fd = open(lckname, O_RDWR | O_CLOEXEC)) < 0)
136 return UU_LOCK_OWNER_ERR;
137 if (get_pid(fd, &err) != getpid())
138 err = UU_LOCK_OWNER_ERR;
139 else {
140 lseek(fd, (off_t)0, SEEK_SET);
141 err = put_pid(fd, pid) ? 0 : UU_LOCK_WRITE_ERR;
142 }
143 close(fd);
144
145 return err;
146}
147
148int
149uu_unlock(const char *tty_name)

Callers

nothing calls this directly

Calls 4

snprintfFunction · 0.85
get_pidFunction · 0.85
put_pidFunction · 0.85
closeFunction · 0.50

Tested by

no test coverage detected