Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-10921

Running "cp -l" in the tests results in the "Bad file descriptor" error on macOS

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None

      Summary

      Our function testutil_copy_data_opt (currently used only in timestamp_abort) creates a copy of the test's data directory with the SAVE extension similarly to testutil_copy_data, except that it creates hard links for files that we expect to not be modified. This helps to improve latency and space utilization of the tests, such as when a lot of data copying is involved due to testing backups.

      The function uses cp -rp -l to create hard links for files in the source directory, which works on Linux. On macOS, it still produces the correct result, but it also prints "Bad file descriptor" to the standard error. The command still returns 0, signifying correct execution.

      Diagnosis

      We believe that this is a bug in the macOS's implementation of cp, which can be quickly confirmed by running the following steps on an empty directory:

      M-W04P92XGQR: ~/Test peter.macko % touch x
      M-W04P92XGQR: ~/Test peter.macko % cp -l x y
      cp: y: Bad file descriptor
      M-W04P92XGQR: ~/Test peter.macko % ls -alh
      total 0
      drwxr-xr-x   4 peter.macko staff  128 Apr 12 14:23 .
      drwxr-x---+ 60 peter.macko staff 1.9K Apr 12 14:21 ..
      -rw-r--r--   2 peter.macko staff    0 Apr 12 14:23 x
      -rw-r--r--   2 peter.macko staff    0 Apr 12 14:23 y 

            Assignee:
            peter.macko@mongodb.com Peter Macko
            Reporter:
            peter.macko@mongodb.com Peter Macko
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: