*/
#include "tests.h"
+#include <errno.h>
#include <stdio.h>
+#include <sys/stat.h>
#include <unistd.h>
int
main(void)
{
+ static const char lockdir[] = "attach-p-cmd.test-lock";
+ /* wait for the lock directory to be created by peer */
+ while (rmdir(lockdir)) {
+ if (ENOENT != errno)
+ perror_msg_and_fail("rmdir: %s", lockdir);
+ }
+
static const char dir[] = "attach-p-cmd.test cmd";
pid_t pid = getpid();
int rc = chdir(dir);
- printf("%-5d chdir(\"%s\") = %d %s (%m)\n"
+ printf("%-5d chdir(\"%s\") = %s\n"
"%-5d +++ exited with 0 +++\n",
- pid, dir, rc, errno2name(), pid);
+ pid, dir, sprintrc(rc), pid);
return 0;
}
*/
#include "tests.h"
+#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
+#include <sys/stat.h>
#include <unistd.h>
static void
{
const struct sigaction act = { .sa_handler = handler };
if (sigaction(SIGALRM, &act, NULL))
- perror_msg_and_skip("sigaction");
+ perror_msg_and_fail("sigaction");
sigset_t mask = {};
sigaddset(&mask, SIGALRM);
if (sigprocmask(SIG_UNBLOCK, &mask, NULL))
- perror_msg_and_skip("sigprocmask");
+ perror_msg_and_fail("sigprocmask");
+
+ static const char lockdir[] = "attach-p-cmd.test-lock";
+ /* create a lock directory */
+ if (mkdir(lockdir, 0700))
+ perror_msg_and_fail("mkdir: %s", lockdir);
+
+ /* wait for the lock directory to be removed by peer */
+ while (mkdir(lockdir, 0700)) {
+ if (EEXIST != errno)
+ perror_msg_and_fail("mkdir: %s", lockdir);
+ }
+
+ /* remove the lock directory */
+ if (rmdir(lockdir))
+ perror_msg_and_fail("rmdir: %s", lockdir);
alarm(1);
pause();
run_prog_skip_if_failed \
kill -0 $$
-run_prog ./attach-p-cmd-cmd > /dev/null
-run_prog ./attach-p-cmd-p > /dev/null
+rm -rf attach-p-cmd.test-lock
rm -f "$OUT"
./set_ptracer_any ./attach-p-cmd-p >> "$OUT" &
tracee_pid=$!
while ! [ -s "$OUT" ]; do
kill -0 $tracee_pid 2> /dev/null ||
- fail_ 'set_ptracer_any sleep failed'
+ fail_ 'set_ptracer_any ./attach-p-cmd-p failed'
done
run_strace -a30 -echdir -p $tracee_pid ./attach-p-cmd-cmd > "$OUT"